From: Roland McGrath Date: Sat, 2 Jun 2007 00:07:33 +0000 (+0000) Subject: 2007-05-24 Jan Kratochvil X-Git-Tag: v4.5.18~225 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=134813ae1ecf7f214440a5a09d5eff15a71bf8e6;p=strace 2007-05-24 Jan Kratochvil * strace.c [LINUX] (my_tgkill): New macro. [LINUX] (detach): Use my_tgkill () instead of kill(2). Fixes RH#240962. --- diff --git a/strace.c b/strace.c index 5e3b8757..1acfd0aa 100644 --- a/strace.c +++ b/strace.c @@ -46,6 +46,21 @@ #include #include +#ifdef LINUX +# include +# if defined __NR_tgkill +# define my_tgkill(pid, tid, sig) syscall (__NR_tgkill, (pid), (tid), (sig)) +# elif defined __NR_tkill +# define my_tgkill(pid, tid, sig) syscall (__NR_tkill, (tid), (sig)) +# else + /* kill() may choose arbitrarily the target task of the process group + while we later wait on a that specific TID. PID process waits become + TID task specific waits for a process under ptrace(2). */ +# warning "Neither tkill(2) nor tgkill(2) available, risk of strace hangs!" +# define my_tgkill(pid, tid, sig) kill ((tid), (sig)) +# endif +#endif + #if defined(IA64) && defined(LINUX) # include #endif @@ -1322,11 +1337,15 @@ int sig; /* Shouldn't happen. */ perror("detach: ptrace(PTRACE_DETACH, ...)"); } - else if (kill(tcp->pid, 0) < 0) { + else if (my_tgkill((tcp->flags & TCB_CLONE_THREAD ? tcp->parent->pid + : tcp->pid), + tcp->pid, 0) < 0) { if (errno != ESRCH) perror("detach: checking sanity"); } - else if (kill(tcp->pid, SIGSTOP) < 0) { + else if (my_tgkill((tcp->flags & TCB_CLONE_THREAD ? tcp->parent->pid + : tcp->pid), + tcp->pid, SIGSTOP) < 0) { if (errno != ESRCH) perror("detach: stopping child"); }