Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions doc/api/child_process.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Child Process
#n Child Process
Copy link
Contributor

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.


> Stability: 2 - Stable

Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't put backticks around man page references

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this getting fixed?

a list of available signals.

```js
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ function onErrorNT(self, err) {
ChildProcess.prototype.kill = function(sig) {
var signal;

if (sig === 0) {
signal = 0;
if (typeof sig === 'number' && sig >>> 0 === sig) {
signal = sig;
} else if (!sig) {
signal = constants['SIGTERM'];
} else {
Expand Down
35 changes: 21 additions & 14 deletions test/parallel/test-child-process-kill.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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it pass sig here?

assert.equal(cat.killed, true);
}

runTest(constants.os.signals.SIGTERM);
runTest('SIGTERM');
Copy link
Member

Choose a reason for hiding this comment

The 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)