-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement send_signal for unix child processes #141990
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
base: master
Are you sure you want to change the base?
Conversation
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use |
cc @tgross35 as this modifies the proposed API slightly - fn send_signal(&self, signal: i32) -> Result<()>;
+ fn send_signal(&mut self, signal: i32) -> Result<()>; |
I didn't put too much thought into what I wrote there, so it's fine if it needs to change. That being said, why does this need to be @Qelxiros could you add documentation and examples here? |
You're right that it doesn't need to be mutable, so I changed it back. I do wonder why e.g. |
No it's not to do with Windows. It seems to have been a deliberate decision in the early days of rust, though I can't find any record of the thinking behind it. It was implemented in #22119 and all the implementations use |
/// # Errors | ||
/// | ||
/// This function will return an error if the signal is invalid. The integer values associated | ||
/// with signals are implemenation-specific, so the use of [`libc`] is encouraged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// with signals are implemenation-specific, so the use of [`libc`] is encouraged. | |
/// with signals are implemenation-specific, so the use of `libc` is encouraged. |
libc
is not a public dependency so linking won't work. Also it might be worth saying something more generic. There are other crates that provide posix bindings (e.g. for safety or other reasons). They might use libc
internally but the user doesn't necessarily need to know that.
Tracking issue: #141975
There are two main differences between my implementation and the Public API section of the tracking issue.
First,Second,send_signal
requires a mutable reference, likeChild::kill
.ChildExt
hasSealed
as a supertrait, bringing it more in line with other extension traits likeCommandExt
.