3 # Ensure that strace can detach from running processes.
5 . "${srcdir=.}/init.sh"
7 run_prog_skip_if_failed \
14 ./set_ptracer_any sh -c "echo > $LOG; while :; do :; done" > /dev/null &
16 while ! [ -s "$LOG" ]; do
17 kill -0 $! 2> /dev/null ||
18 fail_ 'set_ptracer_any sh failed'
28 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 || {
38 dump_log_and_fail_with "$STRACE -p failed to attach"
46 grep -F "Process $tracee_pid detached" "$LOG" > /dev/null || {
48 dump_log_and_fail_with "$STRACE -p failed to detach"
51 if [ -f /proc/self/status ]; then
53 test -d /proc/$tracee_pid || {
55 dump_log_and_fail_with 'tracee died after detach'
57 grep '^State:.*R (running)' < /proc/$tracee_pid/status > /dev/null || {
58 grep '^State:' < /proc/$tracee_pid/status
60 dump_log_and_fail_with 'tracee is not running after detach'