0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/abort/test-signal-handler.js
Anna Henningsen e256204776
src: reset SIGSEGV handler before crashing
Without this, we would re-enter the signal handler immediately
after re-raising the signal, leading to an infinite loop.

PR-URL: https://github.com/nodejs/node/pull/27775
Refs: https://github.com/nodejs/node/pull/27246
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-14 19:11:40 +02:00

24 lines
799 B
JavaScript

'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}`);
}