Sorry. I didn’t explain the use case clearly. I’m building a tool that runs one job at a time in a VM on an Apple silicon Mac. A launcher prepares a directory for the job and starts a helper process. That helper owns the VM. If the job is cancelled, I must not reuse its files while something from that run may still be writing to them.
My question is: can I arrange for macOS itself to stop the helper for that particular run if my launcher gets stuck, or does my design have to assume that another process remains responsive to do it?
Here’s the case I need to cover. The launcher starts creating the helper, but the launch call never returns a PID. The helper may already be alive. A cancellation request then arrives from outside the launcher. The launcher can’t act on it, and the helper’s VM queue isn’t progressing either. The Mac and kernel are otherwise running. I’m not asking another app to take over the VM.
I need to decide two things before allowing a job to start:
Can protection be set up before creating the job directory or launching the helper? If there is a public API or system service for this, how would it receive the cancellation and identify the right helper and any child processes from that run, even if the launch call never returns?
What timing, if any, is documented? Our requirement is to finish the stop attempt, including any required fallback if the first stop operation fails or hangs, within 10 seconds of the original cancellation. That is our requirement, not a deadline we assume macOS promises. We are not asking for a guarantee that the VM has finished shutting down or that its files are safe to reuse within those 10 seconds.
If there’s a supported mechanism that covers only part of this, its name, applicable macOS versions and limits would help. If the design must instead assume a responsive external controller and has no documented 10-second bound, that’s useful too: it tells me not to start jobs that require that guarantee.
Thank you!