]>
git.ipfire.org Git - thirdparty/util-linux.git/commit
unshare: Fix PDEATHSIG race for --kill-child
Kill the child explicitly should the parent terminate
just before the child invokes prctl(PR_SET_PDEATHSIG).
The underlying issue can be reproduced as follows:
#!/bin/bash
rm -f /tmp/unshare.log.*
strace -ff -tt -o /tmp/unshare.log /usr/bin/unshare --kill-child --fork true
head -1 /tmp/unshare.log.*
while : ; do
PARENT=$(
/usr/bin/unshare --kill-child --fork bash -c 'echo $PPID' &
sleep 0 # sleep 0.00$RANDOM
kill -9 $! 2>/dev/null
)
[ "$PARENT" != 1 ] || { echo "$PARENT" ; break ; }
done
Signed-off-by: Earl Chew <earl_chew@yahoo.com>