aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-detached.js
blob: 43cae6eeb02a889e175e060d57892a9305461673 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'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() {
    process.kill(persistentPid);
  });
});