summaryrefslogtreecommitdiff
path: root/test/abort/test-signal-handler.js
blob: f68e6881f6e5b6bcf01dadfdb8d20e22a16940f1 (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';
const common = require('../common');
if (common.isWindows)
  common.skip('No signals on Window');

const assert = require('assert');
const { spawnSync } = require('child_process');

// Test that a hard crash does not cause an endless loop.

if (process.argv[2] === 'child') {
  const { internalBinding } = require('internal/test/binding');
  const { causeSegfault } = internalBinding('process_methods');

  causeSegfault();
} else {
  const child = spawnSync(process.execPath,
                          ['--expose-internals', __filename, 'child'],
                          { stdio: 'inherit' });
  // FreeBSD and macOS use SIGILL for the kind of crash we're causing here.
  assert(child.signal === 'SIGSEGV' || child.signal === 'SIGILL',
         `child.signal = ${child.signal}`);
}