Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When killing the child process, kill all the descendants as well #170

Closed
wants to merge 8 commits into from

Commits on Jan 20, 2019

  1. When killing the child process, kill all the descendents as well

    This is an attempt to fix the problem described by the issue sindresorhus#96.
    If a child process is killed, the descendents of that child process won't be killed as well. This happens on Linux but not on Windows [^1].
    The adopted solution is the "PID range hack" [^2] that uses the `detached` mode for spawning a process and then kills that child process by killing the PID group, using `process.kill(-pid)`, effectively killing all the descendents.
    
    *Implementation*
    
    - added an internal option `killByPid` as a remained for the spawned child process that it will be `detached` and to kill it by PID
    - expanded and moved to a separate function the routine to kill the spawned process to `killSpawned`
    - the `ChildProcess#kill` method of the spawned child process will be replaced by the `killSpawned` routine, to kill by pid if necessary
    - the `killSpawned` routine signals that the child process has been killed, if it has been killed by the pid
    
    I checked and all the tests pass.
    
    This implementation also considers the issue sindresorhus#115 and shouldn't interfere with the detached/cleanup fix.
    
    [^1]: https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal
    [^2]: https://azimi.me/2014/12/31/kill-child_process-node-js.html
    tomsotte committed Jan 20, 2019
    Configuration menu
    Copy the full SHA
    c16cc46 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2019

  1. Merge upstream/master

    tomsotte committed Mar 10, 2019
    Configuration menu
    Copy the full SHA
    a82d9da View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1725e3b View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2019

  1. Configuration menu
    Copy the full SHA
    2b0cecd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6aa5254 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c73e754 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d116af8 View commit details
    Browse the repository at this point in the history
  5. Fixed code styling

    tomsotte committed Mar 21, 2019
    Configuration menu
    Copy the full SHA
    278fa7d View commit details
    Browse the repository at this point in the history