Title: Supported launch code requirement with direct posix_spawn and exclusive child reaping on macOS
I'm designing a security-sensitive process-lifecycle controller on Apple silicon macOS.
The controller directly launches a signed foreground executable and must satisfy two requirements:
- Before any child executable code runs, macOS must enforce a launcher-supplied requirement binding the child to approved code, preferably using
LaunchCodeRequirementandCodeDirectoryHash. - The original parent must retain exclusive ownership of the child's terminal status through
waitpid(), with signalling and reaping serialised by one designated execution context.
I understand that Foundation Process.launchRequirement supports launch-time executable constraints, whereas the established lifecycle currently uses direct posix_spawn().
Could Apple DTS clarify:
1. Is there a supported public API for supplying an equivalent launcher-owned code requirement through direct posix_spawn() or its attributes?
2. If Foundation Process is the supported route, can its caller exclusively consume the direct child's terminal status with waitpid() without competing automatic reaping or status consumption by Foundation? Or must callers use Foundation's own termination reporting?
3. If those requirements cannot be combined through one supported interface, is there a recommended public API or launch topology providing both pre-execution code-requirement enforcement and an attributable terminal-status oracle?
I'm seeking supported contractual behaviour, not private implementation details.
This question concerns executable identity and child lifecycle ownership only. It does not assume that process termination establishes containment of descendants, delegated work or pending external operations.
Thank you.
The answers to your question are in your question:
- The launch constraint facility is API on
Process(and, equivalently,NSTask) but SPI onposix_spawn[1]. - If you use
Processthen it becomes responsible for reaping the child. The facility it uses for this is pretty effective, but if you have a hard constraint that you control the code that callswaitpidthen this isn’t an option for you.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] It should, IMO, be API on posix_spawn and I encourage you to file an enhancement request for that. I’ve suggested this before but the developer didn’t post their bug number so I’ve no idea whether it happened or not. So if you do file a bug about this, please post your bug number.