Title: Supported macOS PID reservation for an exited but unreaped direct child

Title: Supported macOS PID reservation for an exited but unreaped direct child

I'm designing a process-lifecycle experiment on Apple silicon, initially targeting macOS 26.7.2 (build 25G332).

A trusted parent directly launches a foreground child using posix_spawn(). The parent remains alive, exclusively owns reaping, preserves child exit status, and never sets SIGCHLD to SIG_IGN or enables SA_NOCLDWAIT.

The parent may send kill(child_pid, SIGKILL) before obtaining the child's terminal status through waitpid().

POSIX.1-2008 §3.295 describes the PID as the last resource released when a process's lifetime ends. Section 4.13 prohibits PID reuse before that lifetime ends.

Could Apple DTS clarify the supported macOS contract for this sequence?

  1. If the child exits immediately before the kill() call but remains unreaped, is its PID guaranteed not to be reassigned to another process while the original parent retains exclusive reaping authority?
  2. Does this guarantee apply to a child created through posix_spawn() on current Apple silicon macOS releases?
  3. Are there documented exceptions beyond automatic status disposal, competing reapers and parent termination?
  4. What result should the parent expect when kill() targets an already-exited but unreaped child?

The design serialises signaling and reaping, and never signals the numeric PID after status consumption.

This question concerns identity-safe signal targeting, not whether successful kill() establishes termination. The latter is separately verified using waitpid().

I'm seeking a supported API contract rather than empirical observations or private kernel implementation details.

Thank you.

Answered by DTS Engineer in 914818022
Written by levis46 in 855492021

If the child exits immediately before the kill() call but remains unreaped, is its PID guaranteed not to be reassigned to another process while the original parent retains exclusive reaping authority?

Yes. Regardless of how the child terminates it becomes a zombie until it’s reaped. The parent must be able to reap that zombie via one of the wait* system calls. For that to work, the pid must remain valid.

Having said that, life is safer if you work in terms of audit tokens rather than pids, which is something we’ve been discussing here on the forums recently.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Written by levis46 in 855492021

If the child exits immediately before the kill() call but remains unreaped, is its PID guaranteed not to be reassigned to another process while the original parent retains exclusive reaping authority?

Yes. Regardless of how the child terminates it becomes a zombie until it’s reaped. The parent must be able to reap that zombie via one of the wait* system calls. For that to work, the pid must remain valid.

Having said that, life is safer if you work in terms of audit tokens rather than pids, which is something we’ve been discussing here on the forums recently.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"