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

doc: child_process: clarify subprocess.pid can be undefined when ENOENT #37014

Merged
merged 2 commits into from
Feb 22, 2021

Commits on Feb 22, 2021

  1. doc,child_process: pid can be undefined when ENOENT

    From the code `nodejs@8` and up should behave the same:
    github.com/nodejs/node/blame/v8.17.0/lib/internal/child_process.js#L290
    
    And a short test snippet:
    ```js
    const { spawn } = require('child_process')
    
    const subProcess = spawn('non-exist-command')
    subProcess.on('error', (error) =>
    	console.warn('mute Unhandled "error" event:', error))
    console.log('- pid:', subProcess.pid)
    process.nextTick(() => console.log('- after error emit'))
    console.log('== end of test ==')
    ```
    
    Note: the sync spawn result `pid` currently do not follow this pattern.
    
    Co-authored-by: Rich Trott <[email protected]>
    
    PR-URL: nodejs#37014
    Reviewed-By: Antoine du Hamel <[email protected]>
    dr-js authored and aduh95 committed Feb 22, 2021
    Configuration menu
    Copy the full SHA
    c1c98fb View commit details
    Browse the repository at this point in the history
  2. test,child_process: add check for subProcess.pid

    Note: this only add checks for async spawn, as the sync spawn do not
    return a `subProcess`.
    
    PR-URL: nodejs#37014
    Reviewed-By: Antoine du Hamel <[email protected]>
    dr-js authored and aduh95 committed Feb 22, 2021
    Configuration menu
    Copy the full SHA
    1e0cfa3 View commit details
    Browse the repository at this point in the history