-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
child_process: support numeric signal argument to kill. #9651
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Child Process | ||
#n Child Process | ||
|
||
> Stability: 2 - Stable | ||
|
||
|
@@ -821,10 +821,11 @@ within the child process to close the IPC channel as well. | |
added: v0.1.90 | ||
--> | ||
|
||
* `signal` {String} | ||
* `signal` {String|Number} The signal to send, either as a string or number. | ||
Defaults to `'SIGTERM'`. | ||
|
||
The `child.kill()` methods sends a signal to the child process. If no argument | ||
is given, the process will be sent the `'SIGTERM'` signal. See signal(7) for | ||
The `child.kill()` method sends a signal to the child process. If no argument | ||
is given, the process will be sent the `'SIGTERM'` signal. See `signal(7)` for | ||
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 think we don't put backticks around man page references 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. is this getting fixed? |
||
a list of available signals. | ||
|
||
```js | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var spawn = require('child_process').spawn; | ||
var cat = spawn(common.isWindows ? 'cmd' : 'cat'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const spawn = require('child_process').spawn; | ||
const constants = process.binding('constants'); | ||
|
||
cat.stdout.on('end', common.mustCall(function() {})); | ||
cat.stderr.on('data', common.fail); | ||
cat.stderr.on('end', common.mustCall(function() {})); | ||
function runTest(sig) { | ||
const cat = spawn(common.isWindows ? 'cmd' : 'cat'); | ||
|
||
cat.on('exit', common.mustCall(function(code, signal) { | ||
assert.strictEqual(code, null); | ||
assert.strictEqual(signal, 'SIGTERM'); | ||
})); | ||
cat.stdout.on('end', common.mustCall(function() {})); | ||
cat.stderr.on('data', common.fail); | ||
cat.stderr.on('end', common.mustCall(function() {})); | ||
|
||
assert.equal(cat.killed, false); | ||
cat.kill(); | ||
assert.equal(cat.killed, true); | ||
cat.on('exit', common.mustCall(function(code, signal) { | ||
assert.strictEqual(code, null); | ||
assert.strictEqual(signal, 'SIGTERM'); | ||
})); | ||
|
||
assert.equal(cat.killed, false); | ||
cat.kill(); | ||
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. Shouldn't it pass |
||
assert.equal(cat.killed, true); | ||
} | ||
|
||
runTest(constants.os.signals.SIGTERM); | ||
runTest('SIGTERM'); | ||
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. a third test can be added without an argument (to check the default value for signal) |
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.
@gerrard00 You have an extra
n
here. :)We can fix that on landing though.