From 6424bebf49c5519feb21899032ff49857fba4999 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 10 Oct 2023 11:24:32 -0700 Subject: [PATCH] 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. --- tests/pidof.test | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/pidof.test b/tests/pidof.test index 1d0ea567..e56f2cad 100644 --- a/tests/pidof.test +++ b/tests/pidof.test @@ -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" "" "" -- 2.39.2