HomeFreeBSD

proc_detach: use ptrace(PT_KILL) to kill the tracee

Description

proc_detach: use ptrace(PT_KILL) to kill the tracee

When MFC'ing commit dad11f990e2 to stable/12, the child would dump core
when dtrace exited. It was getting SIGTRAP, even though proc_detach
sent a SIGKILL. I could not find the reason for this difference in
behavior from main (and stable/13). The present change, however, works
as expected, probably due the proc_wkilled special case in kern_ptrace.
It also seems like a more obvious approach.

While I'm here, fix two other issues in the previous code:

It would SIGKILL a tracee even in read-only mode.

It would SIGSTOP/SIGCONT the tracee if ptrace succeeded but errno happened
to be EBUSY for some other reason.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D41122

Details

Provenance
vangyzenAuthored on Jul 25 2023, 4:58 PM
Reviewer
markj
Differential Revision
D41122: proc_detach: use ptrace(PT_KILL) to kill the tracee
Parents
rGbcbce2a29b89: dtrace: do not overload libproc flags
Branches
Unknown
Tags
Unknown