Summary
Currently, propolis-runner is spawned as a child process in the same process group as the calling process. This means:
- A
SIGINT from a terminal (Ctrl+C) sends the signal to the entire process group, so both the caller and propolis-runner receive it — which may or may not be desired.
- A targeted
SIGKILL on just the caller process leaves propolis-runner as an orphan in the parent's process group, with no easy way to clean it up by group.
Requested change
Add an option (e.g. WithRunnerProcessGroup() or as part of a RunnerOptions) that sets Setpgid: true in SysProcAttr when spawning propolis-runner. This places the runner in its own process group, giving the caller a stable group ID to target when cleaning up:
// Caller can then do:
syscall.Kill(-pgid, syscall.SIGTERM)
Alternatively, expose the process group ID via a method or the data dir so the caller can use it for targeted cleanup.
Use case
apiary needs to clean up orphaned propolis-runner processes after a crash. With the runner in a dedicated process group, startup cleanup can send SIGTERM to the entire group (runner + any of its own children) safely, without affecting unrelated processes in the parent's group.
Notes
- This option should be opt-in, not default, to avoid breaking existing callers that rely on the current process group behavior.
- On macOS,
Setpgid works the same way via syscall.SysProcAttr.
Summary
Currently,
propolis-runneris spawned as a child process in the same process group as the calling process. This means:SIGINTfrom a terminal (Ctrl+C) sends the signal to the entire process group, so both the caller and propolis-runner receive it — which may or may not be desired.SIGKILLon just the caller process leaves propolis-runner as an orphan in the parent's process group, with no easy way to clean it up by group.Requested change
Add an option (e.g.
WithRunnerProcessGroup()or as part of aRunnerOptions) that setsSetpgid: trueinSysProcAttrwhen spawning propolis-runner. This places the runner in its own process group, giving the caller a stable group ID to target when cleaning up:Alternatively, expose the process group ID via a method or the data dir so the caller can use it for targeted cleanup.
Use case
apiary needs to clean up orphaned propolis-runner processes after a crash. With the runner in a dedicated process group, startup cleanup can send
SIGTERMto the entire group (runner + any of its own children) safely, without affecting unrelated processes in the parent's group.Notes
Setpgidworks the same way viasyscall.SysProcAttr.