|
| 1 | +'use strict'; |
| 2 | +constcommon=require('../common'); |
| 3 | +constassert=require('assert'); |
| 4 | +const{ spawn }=require('child_process'); |
| 5 | + |
| 6 | +// SIGWINCH is a non-terminal signal: sending it must not terminate the target |
| 7 | +// process. On Windows, kill() must surface ENOSYS instead of coercing |
| 8 | +// SIGWINCH into a SIGKILL (which would wrongly terminate the process). |
| 9 | +// Refs: https://github.com/nodejs/node/issues/64324 |
| 10 | + |
| 11 | +constchild=spawn(process.execPath,['-e','setInterval(() => {}, 1000)']); |
| 12 | + |
| 13 | +// The process must survive the SIGWINCH; it is only ever torn down by the |
| 14 | +// explicit SIGKILL in the cleanup below (after the listener is removed). |
| 15 | +child.on('exit',common.mustNotCall('child must survive SIGWINCH')); |
| 16 | + |
| 17 | +child.on('spawn',common.mustCall(()=>{ |
| 18 | +if(common.isWindows){ |
| 19 | +assert.throws(()=>child.kill('SIGWINCH'),{code: 'ENOSYS'}); |
| 20 | +}else{ |
| 21 | +assert.strictEqual(child.kill('SIGWINCH'),true); |
| 22 | +} |
| 23 | + |
| 24 | +assert.strictEqual(child.signalCode,null); |
| 25 | +assert.strictEqual(child.exitCode,null); |
| 26 | + |
| 27 | +setTimeout(common.mustCall(()=>{ |
| 28 | +assert.strictEqual(child.signalCode,null); |
| 29 | +assert.strictEqual(child.exitCode,null); |
| 30 | + |
| 31 | +child.removeAllListeners('exit'); |
| 32 | +child.kill('SIGKILL'); |
| 33 | +}),common.platformTimeout(500)); |
| 34 | +})); |
0 commit comments