1'use strict'; 2 3const { mustCall } = require('../common'); 4const childProcess = require('child_process'); 5const assert = require('assert'); 6 7if (process.env.CHILD === 'true') { 8 main(); 9} else { 10 // Use inherited stdio child process to prevent test tools from determining 11 // the case as crashed from SIGINT 12 const cp = childProcess.spawn( 13 process.execPath, 14 ['--trace-sigint', __filename], 15 { 16 env: { ...process.env, CHILD: 'true' }, 17 stdio: 'inherit' 18 }); 19 cp.on('exit', mustCall((code, signal) => { 20 assert.strictEqual(signal, 'SIGINT'); 21 assert.strictEqual(code, null); 22 })); 23} 24 25function main() { 26 // Deactivate colors even if the tty does support colors. 27 process.env.NODE_DISABLE_COLORS = '1'; 28 process.kill(process.pid, 'SIGINT'); 29 while (true) {} 30} 31