Skip to content

child_process.spawn leaves spawned process hanging #7951

@dignifiedquire

Description

@dignifiedquire
  • Version: 6.3.0
  • Platform: Darwin dignified-station-3.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 23 18:25:34 PDT 2016; root:xnu-3248.60.10~1/RELEASE_X86_64 x86_64
  • Subsystem: child_process

Given the following code

'use strict'

const spawn = require('child_process').spawn

const cmd = 'tail'
const args = ['-f', '/dev/null'/*, '&'*/]
const p = spawn(cmd, args)

console.log('starting')
setTimeout(() => {
  console.log('exiting')
  process.exit()
}, 2 * 1000)

I would expect the spawned process to be terminated when the execution of it terminates, but this does not seem the case. Checking after this code is executed I find

$ ps auxw |grep tail
dignifiedquire  21100   0.0  0.0  2434832    664 s004  S     9:44PM   0:00.00 tail -f /dev/null &

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions