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