mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

This tests child process fork component in detached mode by spawning a parent process that creates a child process. We kill the parent process and check if the child is still running. Fixes: https://github.com/nodejs/node/issues/17592 PR-URL: https://github.com/nodejs/node/pull/24524 Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
24 lines
563 B
JavaScript
24 lines
563 B
JavaScript
'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);
|
|
});
|