mirror of
https://codeberg.org/landley/toybox.git
synced 2026-01-26 06:07:55 +00:00
Fix pidof tests when stdout is a socket
The pidof tests try to block a subprocess forever by reading from stdout via /proc/self/fd/1. This works for most stdout fds, but fails if stdout is a socket, which happens when running the tests in a sandbox in the Android build. Create a named fifo and read on that instead.
This commit is contained in:
parent
61856b336b
commit
6424bebf49
@ -8,7 +8,8 @@
|
||||
# pidof (unlike killall) doesn't match argv[1] unless you supply -x.
|
||||
#
|
||||
|
||||
echo -e "#!$(which sh)\nread i < /proc/self/fd/1" > pidof-$$.test
|
||||
mkfifo fifo
|
||||
echo -e "#!$(which sh)\nread i < fifo" > pidof-$$.test
|
||||
chmod a+x pidof-$$.test
|
||||
cp pidof-$$.test toybox.pidof-$$.test.script
|
||||
(./pidof-$$.test & echo $! > pid.txt)
|
||||
@ -23,7 +24,7 @@ testcmd "long argv[1]" "toybox.pidof-$$.test.script" "" "" ""
|
||||
testcmd "long argv[1] -x" "-x toybox.pidof-$$.test.script" "$pid\n" "" ""
|
||||
kill $pid
|
||||
|
||||
rm -f toybox.pidof-$$.test.script pidof-$$.test pid.txt
|
||||
rm -f toybox.pidof-$$.test.script pidof-$$.test pid.txt fifo
|
||||
|
||||
# pidof (unlike killall) will match itself.
|
||||
testcmd "pidof pidof" "pidof > /dev/null && echo found" "found\n" "" ""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user