[PATCH 83] ptrace(DETACH, SIGKILL) should really kill the tracee

Roland McGrath roland at redhat.com
Mon Oct 12 00:48:59 UTC 2009


> Roland, Jan, what user-space expects ptrace(DETACH, SIGKILL) should do?
> 
> My guess: this should really kill the tracee asap, hence this patch.

As far as killing, it is no more reliable than PTRACE_CONT,SIGKILL.
i.e., will fail if it's not stopped, will be dropped on the floor if
stopped at PTRACE_EVENT_EXEC et al.  So I would not especially try to make
it any more reliable than that, especially if it takes a special case
kludge like that.

For "make it die now", I have been advising people for years to just use
plain kill(,SIGKILL).  That is the one thing we have worked the longest and
most consistently to keep reliable in making things really die really soon.

The one thing that anyone using PTRACE_DETACH,SIGKILL does perhaps expect
is that the detaching and killing are atomic.  That is, it's not possible
for another thread in the tracer's process to get the WIFEXITED wait result
for the tracee.  Conversely, that race is possible if the tracer does:
	kill(pid, SIGKILL);
	ptrace(PTRACE_DETACH, pid, anything);
(And a tracer doesn't want to do them in the other order if it wants to be
sure to go from stopped->dead with no chance of running more user code.)
So IMHO that is the only special wrinkle of PTRACE_DETACH,SIGKILL we need
to worry about for compatibility.  In other senses it needs to work no
better or different from PTRACE_CONT,SIGKILL.


Thanks,
Roland




More information about the utrace-devel mailing list