-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Added interrupt
function for std::process::Child
#101387
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
Added interrupt
function for std::process::Child
#101387
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @joshtriplett (or someone else) soon. Please see the contribution instructions for more information. |
d08a692
to
e43e63b
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
For a new API you'll also need to create an API Change Proposal (ACP) to get approval from the libs-api-team. |
|
@JonathanWoollett-Light any updates on this? |
Seems to maintain consistently with other APIs little will change. It may be:
But you will still need to depend on If you want these kind of safe wrappers, just use Nix https://github.com/nix-rust/nix. |
@JonathanWoollett-Light thanks. does this still need to be a draft? Reviewers are likely not going to review it when a pr is in draft. If it is ready you can click on »Ready for review« and use |
☔ The latest upstream changes (presumably #117285) made this pull request unmergeable. Please resolve the merge conflicts. |
@JonathanWoollett-Light any updates on this? not sure what is pending here. IF nothing is you can mark it as ready |
r? libs |
@Dylan-DPC I need to rebase the PR, I should be able to get around to this by the end of next week. |
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
Added an
interrupt
function tostd::process::Child
which acts similar to thekill
function but uses theSIGINT
signal instead ofSIGKILL
. This allows the process to catch the signal and gracefully exit.When working with binaries this is very important, considering a test where you need to spawn a server, interact with this server, then shutdown the server (this server may create local resources which require manual cleanup) (a little easier and safer than
unsafe { libc::kill(child.id() as i32, libc::SIGINT); }
).It is better practice to interrupt applications to allow graceful shutdowns than to kill applications as this may leave remnants the application was not able to clean up. Really killing should only be used when applications are un-trusted or refuse to gracefully exit.
I would argue,
interrupt
should probably be more commonly used thankill
.Although this is not changed in this PR, it might make sense in the future for
std::process::Child
to implementstd::ops::Drop
like:The Fuschia implementation currently simply mimics
kill
I will look into Fuschia to see if I can fix this (I currently know basically nothing here).ACP: rust-lang/libs-team#97