node/test/parallel/test-process-ppid.js
cjihrig 3cacd34dc2
src: add process.ppid
Fixes: https://github.com/nodejs/node/issues/14957
PR-URL: https://github.com/nodejs/node/pull/16839
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-10 14:27:52 -05:00

17 lines
537 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const cp = require('child_process');
if (process.argv[2] === 'child') {
// The following console.log() call is part of the test's functionality.
console.log(process.ppid);
} else {
const child = cp.spawnSync(process.execPath, [__filename, 'child']);
assert.strictEqual(child.status, 0);
assert.strictEqual(child.signal, null);
assert.strictEqual(+child.stdout.toString().trim(), process.pid);
assert.strictEqual(child.stderr.toString().trim(), '');
}