Skip to content

Option to run propolis-runner in its own process group (Setpgid) #4

@JAORMX

Description

@JAORMX

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions