* strace.c (detach) [USE_SEIZE]: If PTRACE_SEIZE API is in use, stop the tracee using PTRACE_INTERRUPT instead of sending it a SIGSTOP. * tests/detach: New test. * tests/Makefile.am (TESTS): Add it.
Reported-by: Raghavendra D Prabhu <[email protected]> --- Denys, please have a look whether this fix is correct. strace.c | 10 +++++++++- tests/Makefile.am | 2 +- tests/detach | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100755 tests/detach diff --git a/strace.c b/strace.c index 6eab600..e46d7a6 100644 --- a/strace.c +++ b/strace.c @@ -769,7 +769,15 @@ detach(struct tcb *tcp) if (errno != ESRCH) perror_msg("detach: checking sanity"); } - else if (!sigstop_expected && my_tkill(tcp->pid, SIGSTOP) < 0) { +#if USE_SEIZE + else if (!sigstop_expected && use_seize + && ptrace(PTRACE_INTERRUPT, tcp->pid, 0, 0) < 0) { + if (errno != ESRCH) + perror_msg("detach: ptrace(PTRACE_INTERRUPT, ...)"); + } +#endif + else if (!sigstop_expected && !use_seize + && my_tkill(tcp->pid, SIGSTOP) < 0) { if (errno != ESRCH) perror_msg("detach: stopping child"); } diff --git a/tests/Makefile.am b/tests/Makefile.am index a7f584d..debf2b0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ AM_CFLAGS = $(WARN_CFLAGS) check_PROGRAMS = net-accept-connect -TESTS = ptrace_setoptions strace-f qual_syscall stat net +TESTS = ptrace_setoptions strace-f qual_syscall stat net detach EXTRA_DIST = init.sh $(TESTS) diff --git a/tests/detach b/tests/detach new file mode 100755 index 0000000..4b20c2c --- /dev/null +++ b/tests/detach @@ -0,0 +1,38 @@ +#!/bin/sh + +# Ensure that strace can detach. + +. "${srcdir=.}/init.sh" + +check_strace +check_timeout +check_prog sleep +check_prog grep + +exec > check.log 2>&1 +set -e + +sleep 60 & +tracee_pid=$! +kill -STOP $tracee_pid + +$TIMEOUT $STRACE -p $tracee_pid & + +while ! grep '^--- stopped by ' check.log > /dev/null; do + if grep -F Killed check.log > /dev/null; then + exit 1 + fi + sleep 1 +done + +kill -INT $! +wait $! + +kill $tracee_pid +kill -CONT $tracee_pid +wait + +grep -F "Process $tracee_pid detached" check.log > /dev/null || + exit 1 + +exit 0 -- ldv
pgpTcQgkxSZHt.pgp
Description: PGP signature
------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. A cloud service to automate IT design, transition and operations 2. Dashboards that offer high-level views of enterprise services 3. A single system of record for all IT processes http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________ Strace-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/strace-devel
