ash: redirection bug (temporary file reuse, race condition??)
Steffen Nurpmeso
steffen at sdaoden.eu
Tue Jan 17 18:59:38 UTC 2023
Hello.
Imagine this file:
#!/sbin/busybox.static ash
#set -m
(
echo >&2 "inner shell has: $(ps -o pid,pgid $$ | tail -n1)"
) &
echo >&2 "outer shell has: $(ps -o pid,pgid $$ | tail -n1)"
echo >&2 "x is $$, job is $!: $(ps -o pid,pgid $! | tail -n1)"
If in a t2.sh and run it generates this output:
#?0|kent:tmp$ ./t2.sh
outer shell has: 18192 18192
inner shell has: 18192 18192
x is 18192, job is 18193: 18193 18192
#?0|kent:tmp$ ./t2.sh
inner shell has: 18563 18563
outer shell has: 18563 18563
x is 18563, job is 18564: PID PGID
#?0|kent:tmp$ ./t2.sh
inner shell has: 18575 18575
outer shell has: 18575 18575
x is 18575, job is 18576: 18576 18575
#?0|kent:tmp$ ./t2.sh
inner shell has: 18587 18587
outer shell has: 18587 18587
x is 18587, job is 18588: 18588 18587
#?0|kent:tmp$ ./t2.sh
inner shell has: 18621 18621
outer shell has: 18621 18621
x is 18621, job is 18622: PID PGID
#?0|kent:tmp$ ./t2.sh
inner shell has: 18633 18633
outer shell has: 18633 18633
x is 18633, job is 18634: PID PGID
This with and without my $(()) stack B-(.
(On the other hand it must be said that i first thought this,
because my last busybox, from November 8th, generates output like
?0|kent:tmp$ ./t2.sh
inner shell has: PID PGID
outer shell has: PID PGID
x is 6640, job is 6641: PID PGID
#?0|kent:tmp$ ./t2.sh
inner shell has: PID PGID
outer shell has: PID PGID
x is , job is 6792: 6792 6791
ie, it is totally borked. Maybe the miscompilation commit hmm.)
Enabling -m'onitor mode makes it less weird. But this is
a different story and shall be narrated another time.
("Neverending story", badly translated.)
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)
More information about the busybox
mailing list