ptrace: send SIGSTOP and PTRACE_EVENT_STOP for stoppable signal

When a new child stops due to a stoppable-signal after PTRACE_TRACEME,
send a SIGSTOP with a `PTRACE_EVENT_STOP`.
This commit is contained in:
Matthew Leach
2026-01-10 20:45:58 +00:00
committed by Ashwin Naren
parent 3a0e1f80e1
commit 64b337ca63

View File

@@ -26,6 +26,7 @@ const PTRACE_EVENT_EXEC: usize = 4;
const PTRACE_EVENT_VFORK_DONE: usize = 5;
const PTRACE_EVENT_EXIT: usize = 6;
const PTRACE_EVENT_SECCOMP: usize = 7;
const PTRACE_EVENT_STOP: usize = 128;
bitflags::bitflags! {
#[derive(Clone, Copy, PartialEq)]
@@ -120,7 +121,13 @@ impl PTrace {
None => 0,
Some(PTraceState::Running) => 0,
// No masking for real signal delivery.
Some(PTraceState::SignalTrap { .. }) => 0,
Some(PTraceState::SignalTrap { signal, .. }) => {
if signal.is_stopping() {
(PTRACE_EVENT_STOP as i32) << 8
} else {
0
}
}
Some(PTraceState::TracePointHit { hit_point, .. }) => match hit_point {
TracePoint::SyscallEntry | TracePoint::SyscallExit => {
if self.sysgood {