Repository navigation
process: adds 'spawn' event #6421
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,13 @@ log, either periodically (probably best for long-running programs, allowing | |
| you to clear the map, which in the case of a very buggy program could grow | ||
| indefinitely) or upon process exit (more convenient for scripts). | ||
|
|
||
| ## Event: 'spawn' | ||
|
|
||
| Emitted whenever a process calls the internal `child_process.spawn()` and assign | ||
| the child a `pid`. This is useful for bookkeeping - especially for subsequent | ||
| calls to `process.kill()`, in case no reference to `child` was held and hence | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| `child.kill()` is not an option. | ||
|
|
||
| ## Event: 'uncaughtException' | ||
|
|
||
| The `'uncaughtException'` event is emitted when an exception bubbles all the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,6 +303,7 @@ ChildProcess.prototype.spawn = function(options) { | |
| } | ||
|
|
||
| this.pid = this._handle.pid; | ||
| process.emit('spawn', this.pid); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd do this in nextTick...
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, should be in |
||
|
|
||
| stdio.forEach(function(stdio, i) { | ||
| if (stdio.type === 'ignore') return; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| 'use strict'; | ||
| const common = require('../common'); | ||
| const assert = require('assert'); | ||
| const spawn = require('child_process').spawn | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please run |
||
| const sym = Symbol(); | ||
|
|
||
| process.on('normal', common.mustCall((data) => { | ||
|
|
@@ -20,3 +21,7 @@ process.emit(sym, 'symbolData'); | |
| process.emit('SIGPIPE', 'signalData'); | ||
|
|
||
| assert.strictEqual(isNaN(process._eventsCount), false); | ||
|
|
||
| process.on('spawn', common.mustCall((pid) => { | ||
| assert.strictEqual(isNaN(pid), false); | ||
| })) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sentence is a little awkward.
Also,
assigns.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would make it: