node/test/parallel/test-process-kill-null.js
Luigi Pinca fa8315cb68
test: refactor test-process-kill-null
Use `common.mustCall()` instead of `called` variable.

PR-URL: https://github.com/nodejs/node/pull/16236
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-11-28 13:10:34 +09:00

21 lines
456 B
JavaScript

'use strict';
const { mustCall } = require('../common');
const assert = require('assert');
const { spawn } = require('child_process');
const cat = spawn('cat');
assert.ok(process.kill(cat.pid, 0));
cat.on('exit', mustCall(function() {
assert.throws(function() {
process.kill(cat.pid, 0);
}, Error);
}));
cat.stdout.on('data', mustCall(function() {
process.kill(cat.pid, 'SIGKILL');
}));
// EPIPE when null sig fails
cat.stdin.write('test');