-
Notifications
You must be signed in to change notification settings - Fork 694
Add killpg #1034
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
Add killpg #1034
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -680,6 +680,22 @@ pub fn kill<T: Into<Option<Signal>>>(pid: ::unistd::Pid, signal: T) -> Result<() | |
Errno::result(res).map(drop) | ||
} | ||
|
||
/// Send a signal to a process group [(see | ||
/// killpg(3))](http://pubs.opengroup.org/onlinepubs/9699919799/functions/killpg.html). | ||
/// | ||
/// If `pgrp` less then or equal 1, the behavior is platform-specific. | ||
/// If `signal` is `None`, `killpg` will only preform error checking and won't | ||
/// send any signal. | ||
pub fn killpg<T: Into<Option<Signal>>>(pgrp: ::unistd::Pid, signal: T) -> Result<()> { | ||
let res = unsafe { libc::killpg(pgrp.into(), | ||
match signal.into() { | ||
Some(s) => s as libc::c_int, | ||
None => 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why would you ever want to send 0? Is that even valid? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's valid. It just perform error checking and won't send any signal. According to the POSIX spec of
And in the POSIX spec of
Also in the manpage of
|
||
}) }; | ||
|
||
Errno::result(res).map(drop) | ||
} | ||
|
||
pub fn raise(signal: Signal) -> Result<()> { | ||
let res = unsafe { libc::raise(signal as libc::c_int) }; | ||
|
||
|
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.
The docs should say what the arguments mean. It's not obvious why
signal
should be anOption
. Also, I see from the man page thatkillpg
does something special whenpgrp
is 0. Perhaps that should be an option too?