-
Notifications
You must be signed in to change notification settings - Fork 0
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
birdseye is not fully closed upon exit of birdseye #11
Comments
https://stackoverflow.com/questions/33325301/killing-a-bash-script-does-not-kill-child-processes This looks like it might work |
Nevermind - doesn't work for windows :/ Open a process with detached on windows causes the process to pop open with a console window. Apparently killing all children is not supported on windows :( Or at least not with node - I could spin up a subprocess to nuke them in another language. This guy did exactly that: http://krasimirtsonev.com/blog/article/Nodejs-managing-child-processes-starting-stopping-exec-spawn |
Confirmed fixed on windows :D Still need to test on ubuntu import {exec} from 'child_process'
/**
* kills the process and all its children
* If you are on linux process needs to be launched in detached state
* @param pid process identifier
* @param signal kill signal
*/
export function killAll(pid:number, signal:string|number='SIGKILL'){
if(process.platform == "win32"){
exec(`taskkill /PID ${pid} /T /F`, (error, stdout, stderr)=>{
console.log("stdout: " + stdout)
console.log("stdout: " + stderr)
if(error){
console.log("error: " + error.message)
}
})
}
else{
// see https://nodejs.org/api/child_process.html#child_process_options_detached
// If pid is less than -1, then sig is sent to every process in the process group whose ID is -pid.
process.kill(-pid, signal)
}
} |
Well forgot to test on ubuntu but I just tested on mac and it looks like it works
@alexmojaki I published a medium article on how to kill processes with node - does the explanation make sense? Any thoughts? https://medium.com/@almenon214/killing-processes-with-node-772ffdd19aad |
It looks mostly fine. Some small points:
|
good catch. Fixed typo made in 5280cd2 and the gist. Updated the article to change the title and name. https://medium.com/@almenon214/killing-processes-with-node-772ffdd19aad |
When the user closes birdseye I close the process I started. This works.
The problem is that birdseye launches a second python process (I'm guessing the server) - I need to find some multi-platform way of closing that as well.
There should be some way of identifying child process - but I did not see any grandchildren of my process in the debugger.
Or maybe there is a way of killing a process and all of its children all at once?
The text was updated successfully, but these errors were encountered: