From: Denys Vlasenko Date: Tue, 17 Mar 2009 14:46:54 +0000 (+0000) Subject: Remove "better attach to SIGSTOP", it is not correct... X-Git-Tag: v4.5.19~64 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aab52cae4cf597a556911fec3ef4cb5803a95b12;p=strace Remove "better attach to SIGSTOP", it is not correct... (^C fix remains). --- diff --git a/ChangeLog b/ChangeLog index f5ff8a2f..566b1347 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,6 @@ 2009-03-17 Denys Vlasenko - * strace.c (startup_attach): Take care to correctly attach - to stopped processes by resending SIGSTOP. - (collect_stopped_tcbs): Check for ^C here, not in trace(). + * strace.c (collect_stopped_tcbs): Check for ^C here, not in trace(). (trace): Remove check for ^C. 2009-03-10 Denys Vlasenko diff --git a/strace.c b/strace.c index 864e7f40..e275bfd1 100644 --- a/strace.c +++ b/strace.c @@ -437,15 +437,9 @@ startup_attach(void) if (tid <= 0) continue; ++ntid; - if (ptrace(PTRACE_ATTACH, tid, (char *) 1, 0) < 0) { + if (ptrace(PTRACE_ATTACH, tid, (char *) 1, 0) < 0) ++nerr; - continue; - } -#if defined LINUX && defined __NR_tkill - syscall(__NR_tkill, tid, SIGSTOP); - ptrace(PTRACE_CONT, tid, 0, 0); -#endif - if (tid != tcbtab[tcbi]->pid) { + else if (tid != tcbtab[tcbi]->pid) { tcp = alloctcb(tid); tcp->flags |= TCB_ATTACHED|TCB_CLONE_THREAD|TCB_CLONE_DETACHED; tcbtab[tcbi]->nchildren++; @@ -453,14 +447,14 @@ startup_attach(void) tcbtab[tcbi]->nclone_detached++; tcp->parent = tcbtab[tcbi]; } + if (interactive) { + sigprocmask(SIG_SETMASK, &empty_set, NULL); + if (interrupted) + return; + sigprocmask(SIG_BLOCK, &blocked_set, NULL); + } } closedir(dir); - if (interactive) { - sigprocmask(SIG_SETMASK, &empty_set, NULL); - if (interrupted) - return; - sigprocmask(SIG_BLOCK, &blocked_set, NULL); - } ntid -= nerr; if (ntid == 0) { perror("attach: ptrace(PTRACE_ATTACH, ...)"); @@ -482,14 +476,6 @@ startup_attach(void) droptcb(tcp); continue; } -#if defined LINUX && defined __NR_tkill - /* If process was SIGSTOPed, and waited for, - even before attach, we will never get SIGSTOP - notification. This works around it. - Borrowed from GDB, thanks Jan! */ - syscall(__NR_tkill, tcp->pid, SIGSTOP); - ptrace(PTRACE_CONT, tcp->pid, 0, 0); -#endif /* INTERRUPTED is going to be checked at the top of TRACE. */ if (daemonized_tracer) {