bash script, phpunit 9.6 and 10: stty: 'standard input': Inappropriate ioctl for device

365 views Asked by At

I do understand it has something to do with stty and the console but it is still strange, I have been doing this for ages under konsole. Also I understand it may not be exactly an error in phpunit, and so far I was able to relate it while working with inotifywait:

invocation is done like this:

inotifywait -m --format %w%f  --exclude "(\.\*|../logs|../tests/out)" -q -r -e close_write ../  | \
while read CUAL ; do
    if [ $? == 0 ]; then
        phpunit --no-configuration --color ../tests/testsSuiteREST.php
    fi
done

partial output from a test suite using version 9.6.7:

stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
PHPUnit 9.6.7 by Sebastian Bergmann and contributors.

..                                                                  2 / 2 (100%)

output from version 10 (which includes another new error not present in previous versions):

rudy@rudy:~/37sur/37RestApi/37RestApi$ true | phpunit.10 
tests/testsSuiteREST.php  stty: 'standard input': Inappropriate ioctl for device
stty: 'standard input': Inappropriate ioctl for device
PHP Fatal error:  Cannot override final method PHPUnit\Framework\TestSuite::__construct() in /var/www/htdocs/37RestApi/37RestApi/tests/testsSuiteREST.php on line 33 
rudy@rudy:~/37sur/37RestApi/37RestApi$

partial output from previous version 9.5:


PHPUnit 9.5.24 #StandWithUkraine

..                                                                  2 / 2 (100%)

the only change is the phpunit.phar itself.

I expect no error as it used to. If I run the command manually I don't get the error, nor if I comment out the inotifywait and while lines

Edit: per @user1934428 's request:

rudy@rudy:~/37sur/37SurWeb$ stty -a
speed 38400 baud; rows 41; columns 82; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl
echoke -flusho -extproc

edit 2: as per suggestion, I tried this:

inotifywait -m --format %w%f --exclude "(.*|../logs|../tests/out)" -q -r -e close_write ../ | \ phpunit --no-configuration --color ../tests/testsSuiteREST.php

output was the same.

as per request from @user14967413 I got a section from debug.log using strace:

                   = 0x1c4b000
inotify_init()                          = 3
openat(AT_FDCWD, "/dev/null", O_WRONLY|O_CREAT|O_APPEND, 0666) = 4
lseek(4, 0, SEEK_END)                   = 0
newfstatat(4, "", {st_mode=S_IFCHR|0666, st_rdev=makedev(0x1, 0x3), ...}, AT_EMPTY_PATH) = 0
ioctl(4, TCGETS, 0x7ffe85312130)        = -1 ENOTTY (Inappropriate ioctl for device)
write(4, "\n", 1)                       = 1
close(4)                                = 0
openat(AT_FDCWD, "../", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 4

seems like it's trying to get

ioctl(4, TCGETS, 0x7ffe85312130)

from /dev/null which triggers the error.

edit:

not a real tragedy, I could add

2>/dev/null

to the phpunit command but I run the risk of missing another error.

Update: I was able to replicate the behavior on bash simply by using

true | phpunit --no-configuration --color ../tests/testsSuiteREST.php

output gave me the stty error message. So I take it the error has more to do with bash.

update 2023 08 16 created a issue at the repo but it was ignored by the author. had to downgrade to 9.5, at least until I fix it myself.-

0

There are 0 answers