Skip to content

Instantly share code, notes, and snippets.

@MylesBorins
Created August 16, 2017 01:42
Show Gist options
  • Save MylesBorins/6e447f5de4cbac81379855277b6170dd to your computer and use it in GitHub Desktop.
Save MylesBorins/6e447f5de4cbac81379855277b6170dd to your computer and use it in GitHub Desktop.
'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const spawn = require('child_process').spawn;
const childPath = path.join(common.fixturesDir,
'parent-process-nonpersistent.js');
let persistentPid = -1;
const child = spawn(process.execPath, [ childPath ]);
child.stdout.on('data', function(data) {
persistentPid = parseInt(data, 10);
});
process.on('exit', function() {
assert.notStrictEqual(persistentPid, -1);
assert.throws(function() {
process.kill(child.pid);
}, /^Error: kill ESRCH$/);
assert.doesNotThrow(function() {
try {
process.kill(persistentPid);
}
catch (e) {
console.log(e)
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment