Skip to content

Clean up the entireCommands child process group by default #5303

Description

@fubhy

Commands that spawn child processes can sometimes leave sub-sub-processes lingering if the invoked Command does not reap them on its own.

Counterintuitively, I think we should be leveraging the detached: true flag by default to address this. This would be in-line with the scoped managed resource approach that Effect is already taking with Command execution today. Whether we should offer an escape hatch for this default or not I don't have an opinion on.

First of all, note that detached: true behavior differs by platform. More about that here: https://nodejs.org/api/child_process.html#child_process_options_detached

I'm proposing that we set detached: true by default for non-windows systems.

detached: process.platform !== "win32"

This will cause the new process to be assigned as a leader of a new process group that can then be terminated in its entirety at our discretion.

Instead of just forwarding a kill signal to the process handle (handle.kill(signal)), we'd then utilise taskkill with /T on windows (kill the entire process tree) and process.kill(-pid, signal) (negative pid to kill the entire process group) on non-windows systems.

References:

https://nodejs.org/api/child_process.html#child_process_options_detached
https://github.com/Kikobeats/kill-process-group/blob/master/src/index.js

Activity

  1. fubhy commented on Jul 9, 2026

    @fubhy
    MemberAuthor

    Closing as implemented. The current Node command executor starts non-Windows commands detached and cleans up the process group/tree via process.kill(-pid, signal) or taskkill /T on Windows.

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