summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-fork-detached.js
blob: 87c15173284dbe1b244c89963277f81aa2662a0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
require('../common');
const assert = require('assert');
const fork = require('child_process').fork;
const fixtures = require('../common/fixtures');

const nonPersistentNode = fork(
  fixtures.path('parent-process-nonpersistent-fork.js'),
  [],
  { silent: true });

let childId = -1;

nonPersistentNode.stdout.on('data', (data) => {
  childId = parseInt(data, 10);
  nonPersistentNode.kill();
});

process.on('exit', () => {
  assert.notStrictEqual(childId, -1);
  // Killing the child process should not throw an error
  process.kill(childId);
});