3 # Ensure that strace can detach from stopped processes.
5 . "${srcdir=.}/init.sh"
13 ./set_ptracer_any sleep $((2*$TIMEOUT_DURATION)) > $LOG &
15 while ! [ -s $LOG ]; do
16 kill -0 $! 2> /dev/null ||
17 fail_ 'set_ptracer_any sleep failed'
22 kill -STOP $tracee_pid
28 kill -CONT $tracee_pid
29 wait $tracee_pid 2> /dev/null
33 $STRACE -p $tracee_pid 2> $LOG &
35 while ! grep -F "Process $tracee_pid attached" $LOG > /dev/null; do
36 kill -0 $! 2> /dev/null ||
37 { cat $LOG; cleanup; fail_ 'strace -p does not work'; }
41 while ! grep -F -e '--- stopped by ' $LOG > /dev/null; do
42 kill -0 $! 2> /dev/null ||
43 { cat $LOG; cleanup; fail_ 'strace -p does not work'; }
50 grep -F "Process $tracee_pid detached" $LOG > /dev/null ||
51 { cat $LOG; cleanup; fail_ 'strace -p failed to detach'; }
53 if [ -f /proc/self/status ]; then
55 test -d /proc/$tracee_pid ||
56 { cat $LOG; cleanup; fail_ 'tracee died after detach'; }
57 grep '^State:.*T (stopped)' < /proc/$tracee_pid/status > /dev/null || {
59 grep '^State:' < /proc/$tracee_pid/status
61 fail_ 'tracee is not group-stopped after detach'