node/test/parallel/test-child-process-detached.js
Chris Bystrek a090899e93 test: assert.throws() should include a RegExp
PR-URL: https://github.com/nodejs/node/pull/997://github.com/nodejs/node/pull/9976
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-12-20 17:21:56 -05:00

26 lines
650 B
JavaScript

'use strict';
require('../common');
var assert = require('assert');
var path = require('path');
var spawn = require('child_process').spawn;
var childPath = path.join(__dirname, '..', 'fixtures',
'parent-process-nonpersistent.js');
var persistentPid = -1;
var child = spawn(process.execPath, [ childPath ]);
child.stdout.on('data', function(data) {
persistentPid = parseInt(data, 10);
});
process.on('exit', function() {
assert(persistentPid !== -1);
assert.throws(function() {
process.kill(child.pid);
}, /^Error: kill ESRCH$/);
assert.doesNotThrow(function() {
process.kill(persistentPid);
});
});