Skip to content

platform-node-shared: NodeChildProcessSpawner signals a process group for detached: false commands #10841

Done

Description

@DivMode

What happens

NodeChildProcessSpawner (packages/platform/node-shared/src/NodeChildProcessSpawner.ts) decides whether a child owns a process group with:

const ownsProcessGroup = (command, childProcess) =>
  command.options.detached !== false || !hasExited(childProcess)

So a command spawned with detached: false is treated as a group leader while it is running. Termination and the liveness probe then signal the negative pid, process.kill(-childProcess.pid, signal), before falling back to childProcess.kill(signal).

A non-detached child shares its parent's process group and is not a group leader. kill(-pid) for it targets a group that does not belong to it. Today that fails with ESRCH and the fallback runs, so behaviour is usually correct. But:

  • the spawner issues a group signal for a command that explicitly opted out of having a group;
  • environments that forbid or audit group signals (sandboxes, supervisors, policy hooks) cannot use detached: false to stay within that rule.

Expected

With detached: false, the spawner signals only the child's own pid, and never probes or signals a process group.

Suggested fix

const ownsProcessGroup = (command, childProcess) =>
  command.options.detached !== false

Detached commands keep the current group semantics, which signal the group they created. Non-detached commands go straight to childProcess.kill(signal), and isProcessAlive falls back to the leader's own exit state.

Observed in @effect/platform-node-shared 4.1.5, and unchanged on main.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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