1'use strict'; 2const common = require('../common'); 3if (common.isWindows) 4 common.skip('No signals on Window'); 5 6const assert = require('assert'); 7const { spawnSync } = require('child_process'); 8 9// Test that a hard crash does not cause an endless loop. 10 11if (process.argv[2] === 'child') { 12 const { internalBinding } = require('internal/test/binding'); 13 const { causeSegfault } = internalBinding('process_methods'); 14 15 causeSegfault(); 16} else { 17 const child = spawnSync(process.execPath, 18 ['--expose-internals', __filename, 'child'], 19 { stdio: 'inherit' }); 20 // FreeBSD uses SIGILL for this kind of crash. 21 // macOS uses SIGILL or SIGTRAP (arm64) for this kind of crash. 22 assert(child.signal === 'SIGSEGV' || child.signal === 'SIGILL' || 23 child.signal === 'SIGTRAP', `child.signal = ${child.signal}`); 24} 25