summaryrefslogtreecommitdiff
path: root/test/parallel/test-process-ppid.js
blob: d78ef3a2dd9ae7d7c0d8c71b508601952b038b53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'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(), '');
}