pkrumins / node-tree-kill

kill trees of processes
MIT License
333 stars 37 forks source link

Issue with providing callback but no signal #18

Closed mbhall88 closed 6 years ago

mbhall88 commented 7 years ago

When using kill(), if I pass it the pid and a callback, but no signal as in this example:

kill(process.pid, function(err){
    if(err){
        console.log(err);
    }
    // do something
});

I get the following error:

Error: Unknown signal: function (err){
            if(err){
                console.log(err);
            } else {
                console.log("Child process killed.");
            }
        }

It looks like the function can't handle not being given a signal if it is given a callback function. If I do the same code, but with the default signal 'SIGTERM' as well, it works fine.

I would offer to fix but I don't really know how (would love to learn though).

billiegoose commented 6 years ago

Ah. Yep, guess I didn't think of that possibility. I guess the solution would be to do a check at the beginning: if typeof signal === function and callback === undefined then set callback = signal and set signal = 'SIGTERM'. I ought to be able to do that pretty quickly.

billiegoose commented 6 years ago

Published in v1.2.0