Skip to content

child_process 'close' always (?) emitted after 'exit' #37998

Description

@addaleax
  • Version: master
  • Platform: Linux 5.4.0-70-generic Mani #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linuxd
  • Subsystem: child_process

What steps will reproduce the bug?

const child_process = require('child_process');
const proc = child_process.spawn('bash', ['-c', 'exec 0>&- 1>&- 2>&-; sleep 5'], {
  stdio: ['inherit', 'pipe', 'inherit']
});
proc.stdout.pipe(process.stdout);
proc.on('exit', () => console.log('exit'));
proc.on('close', () => console.log('close'));

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

'close' should be emitted immediately (all stdio streams are closed), 'exit' after 5 seconds

What do you see instead?

5 seconds pass, then 'exit' is emitted and then 'closed'

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

    child_processIssues and PRs related to the child_process subsystem.docIssues and PRs related to Node.js documentation.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions