Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it not possible to kill shelled process? #419

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/kill.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,30 @@ test('kill("SIGKILL") should terminate cleanly', async t => {

const {signal} = await t.throwsAsync(subprocess);
t.is(signal, 'SIGKILL');
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));
})
Comment on lines +33 to +40
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test hangs the test-suite for the duration of the sleep, waiting for the process to stop

}

// `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') {
Expand Down