From 4d404c13d1576f623fc8d892fdeb76be139b36d3 Mon Sep 17 00:00:00 2001 From: Jon Lauridsen Date: Sun, 12 Apr 2020 12:06:57 +0200 Subject: [PATCH 1/2] Ensure "kill("SIGKILL") should terminate cleanly" stopped its process --- test/kill.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/kill.js b/test/kill.js index b402c42d12..6e732ac044 100644 --- a/test/kill.js +++ b/test/kill.js @@ -16,6 +16,7 @@ test('kill("SIGKILL") should terminate cleanly', async t => { const {signal} = await t.throwsAsync(subprocess); t.is(signal, 'SIGKILL'); + t.false(isRunning(subprocess.pid)); }); // `SIGTERM` cannot be caught on Windows, and it always aborts the process (like `SIGKILL` on Unix). From 67ff34fc45c6cb6ccfc605c39769662871920379 Mon Sep 17 00:00:00 2001 From: Jon Lauridsen Date: Sun, 12 Apr 2020 12:07:12 +0200 Subject: [PATCH 2/2] Test `kill` should kill a shell process cleanly --- test/kill.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/kill.js b/test/kill.js index 6e732ac044..a95574874e 100644 --- a/test/kill.js +++ b/test/kill.js @@ -19,6 +19,27 @@ test('kill("SIGKILL") should terminate cleanly', async t => { t.false(isRunning(subprocess.pid)); }); +// `sleep` is a Linux command so these tests do not make sense on Windows. +if (process.platform !== 'win32') { + test('`kill` should kill a process cleanly', async t => { + const subprocess = execa('sleep', ['200'], { stdio: ['ipc'] }); + + subprocess.kill('SIGTERM', { forceKillAfterTimeout: 2000 }); + + await t.throwsAsync(subprocess); + t.false(isRunning(subprocess.pid)); + }); + + test('`kill` should kill a shell process cleanly', async t => { + const subprocess = execa('sleep', ['200'], { shell: true, stdio: ['ipc'] }); + + subprocess.kill('SIGTERM', { forceKillAfterTimeout: 2000 }); + + await t.throwsAsync(subprocess); + t.false(isRunning(subprocess.pid)); + }) +} + // `SIGTERM` cannot be caught on Windows, and it always aborts the process (like `SIGKILL` on Unix). // Therefore, this feature and those tests do not make sense on Windows. if (process.platform !== 'win32') {