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

Change kill signal and add unit test #91

Merged
merged 2 commits into from
May 19, 2020
Merged

Conversation

carnun
Copy link
Contributor

@carnun carnun commented May 19, 2020

I noticed that my package.json scripts weren't being killed after the update to version 2.4.6. If I read the documentation correctly (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/kill.html) the actual kill command should be kill -15.

This PR contains that update as well as a unit test to hopefully check the positive and negative case.

lib/killer.js Outdated
@@ -2,7 +2,7 @@ const psTree = require('ps-tree');
const spawn = require('cross-spawn');
const { exec } = require('child_process');

let KILL_SIGNAL = '15'; // SIGTERM
let KILL_SIGNAL = '-15'; // SIGTERM
Copy link
Owner

Choose a reason for hiding this comment

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

This should remain 15

lib/killer.js Outdated
@@ -21,10 +21,10 @@ module.exports = function kill(child) {
} else {
if (hasPS) {
psTree(child.pid, function(err, kids) {
spawn('kill', ['-s', KILL_SIGNAL, child.pid].concat( kids.map(p => p.PID) )).on('close', resolve);
spawn('kill', [KILL_SIGNAL, child.pid].concat( kids.map(p => p.PID) )).on('close', resolve);
Copy link
Owner

Choose a reason for hiding this comment

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

here you should use '-' + KILL_SIGNAL

lib/killer.js Outdated
});
} else {
exec('kill -s ' + KILL_SIGNAL + ' ' + child.pid, resolve);
exec('kill ' + KILL_SIGNAL + ' ' + child.pid, resolve);
Copy link
Owner

Choose a reason for hiding this comment

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

also here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do, I wasn't sure which way around you wanted it. Will fix up and update the PR.

@gilamran
Copy link
Owner

Thanks for the PR!
Please note that you also have to change the package version.

@carnun carnun requested a review from gilamran May 19, 2020 21:03
@carnun
Copy link
Contributor Author

carnun commented May 19, 2020

@gilamran at first I got spooked by the test failing, but then I saw that it was node6. Do you plan on keeping support for node6?

@gilamran gilamran merged commit 81a2602 into gilamran:master May 19, 2020
@gilamran
Copy link
Owner

Published version 4.2.7, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants