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

some way to kill a running process? #27

Closed
oconnor663 opened this issue Jan 6, 2017 · 9 comments
Closed

some way to kill a running process? #27

oconnor663 opened this issue Jan 6, 2017 · 9 comments

Comments

@oconnor663
Copy link
Owner

Probably start will need to keep more data around. We might need another type of explicit tree to mirror the expression tree, which knows how to wait and kill its children, similar to Rust's stdlib.

@oconnor663
Copy link
Owner Author

This is going to run into an issue with then. If there's a worker thread sitting on wait on the child process, there's no way to kill it, because both methods require &mut self. r/rust question: https://www.reddit.com/r/rust/comments/5lk1lw/hey_rustaceans_got_an_easy_question_ask_here_12017/dc3fft3/

@oconnor663
Copy link
Owner Author

oconnor663 commented Jan 16, 2017

It's possible we could use process groups on Unix and Windows to handle killing. See:

@oconnor663
Copy link
Owner Author

Ah and there's Rust stdlib support for this kind of: https://doc.rust-lang.org/std/os/unix/process/trait.CommandExt.html

@oconnor663
Copy link
Owner Author

Process groups is designed for this sort of thing, and I think I can get it working. However, it has one huge downside, which is that taking child processes out of the parent's group means that Ctrl-C no longer the children automatically (by sending a signal to the parent's entire group). I'm not sure there's a workaround for this that doesn't require the parent to specially handle that signal, as I think shells do.

@oconnor663
Copy link
Owner Author

oconnor663 commented Jan 23, 2017

OMG NO! There's a chance this can work for real. There's a WNOWAIT flag that a bunch of different interfaces support, to allow waiting without reaping. We could use that to get safe kills? (And waiting using our own library calls on the PID would let us call kill later on the handle, which is nice.)

This sort of thing seems to be the norm on Windows, where PIDs don't get recycled until all handles are closed. That's actually a lot nicer than Unix :p https://blogs.msdn.microsoft.com/oldnewthing/20110107-00/?p=11803/

@oconnor663
Copy link
Owner Author

Relevant: rust-lang/rust#38903

@oconnor663
Copy link
Owner Author

Looks like libc includes waitid: rust-lang/libc#489

@oconnor663
Copy link
Owner Author

Maybe it's ok to accept a race condition on OSX here? We kind of have to with no pipe2 support anyway.

@oconnor663
Copy link
Owner Author

0304db7

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

No branches or pull requests

1 participant