Page MenuHomeFreeBSD

kern: send parent a SIGCHLD when the debugger has detached
ClosedPublic

Authored by kevans on Jun 18 2025, 6:23 PM.
Tags
None
Referenced Files
F132413734: D50917.id157317.diff
Thu, Oct 16, 5:47 PM
F132407360: D50917.id157285.diff
Thu, Oct 16, 4:30 PM
Unknown Object (File)
Wed, Oct 15, 6:12 PM
Unknown Object (File)
Wed, Oct 15, 5:04 PM
Unknown Object (File)
Wed, Oct 15, 3:45 PM
Unknown Object (File)
Tue, Oct 14, 2:29 PM
Unknown Object (File)
Tue, Oct 14, 2:29 PM
Unknown Object (File)
Tue, Oct 14, 2:29 PM

Details

Summary

The practical scenario that leads to this is porch(1) spawning some
utility and sending it a SIGSTOP as a debugging aide. The user then
attaches a debugger and walks through how some specific input is
processed, then detaches to allow the script to continue. When ptrace
is detached, the process resumes execution but the parent is never
notified and may be stuck in wait(2) for it to continue or terminate.

Other platforms seem to re-suspend the process after the debugger is
detached, but neither behavior seems unreasonable. Just notifying the
parent that the child has resumed is a relatively low-risk departure
from our current behavior and had apparently been considered in the
past, based on pre-existing comments.

Move p_flag and p_xsig handling into childproc_continued(), as just
sending the SIGCHLD here isn't really useful without P_CONTINUED set
and the other caller already sets these up as well.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added inline comments.
sys/kern/kern_sig.c
3779

Assert the p is locked (no need to assert p_pptr there).

This revision is now accepted and ready to land.Jun 18 2025, 6:26 PM

Should we note this behaviour in ptrace.2?

Assert that we have the proc lock and note the new behavior in ptrace(2)

This revision now requires review to proceed.Jun 19 2025, 12:11 AM
lib/libsys/ptrace.2
476

Start new paragraph.

481

A note could be added to wait.2, it would be even more natural. I do not suggest to remove this text.

Address review commentary:

  • Add a paragraph break in the PT_DETACH description
  • Also note the wait(2) interaction in that paragraph, to be explicit
  • Amend the WCONTINUED description in wait(2) to note that ptrace(2) may cause the process to be noted as continued as well, not just a SIGCONT.
kib added inline comments.
lib/libsys/wait.2
457
This revision is now accepted and ready to land.Jun 19 2025, 12:47 AM