3 # Ensure that strace can detach from running processes.
5 . "${srcdir=.}/init.sh"
12 ./set_ptracer_any sh -c "echo > $LOG; while :; do :; done" > /dev/null &
14 while ! [ -s $LOG ]; do
15 kill -0 $! 2> /dev/null ||
16 fail_ 'set_ptracer_any sh failed'
26 wait $tracee_pid 2> /dev/null
30 $STRACE -p $tracee_pid 2> $LOG &
32 while ! grep -F "Process $tracee_pid attached" $LOG > /dev/null; do
33 kill -0 $! 2> /dev/null ||
34 { cat $LOG; cleanup; fail_ 'strace -p does not work'; }
41 grep -F "Process $tracee_pid detached" $LOG > /dev/null ||
42 { cat $LOG; cleanup; fail_ 'strace -p failed to detach'; }
44 if [ -f /proc/self/status ]; then
46 test -d /proc/$tracee_pid ||
47 { cat $LOG; cleanup; fail_ 'tracee died after detach'; }
48 grep '^State:.*R (running)' < /proc/$tracee_pid/status > /dev/null || {
50 grep '^State:' < /proc/$tracee_pid/status
52 fail_ 'tracee is not running after detach'