File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -380,12 +380,34 @@ impl ExitStatusExt for process::ExitStatusError {
380380
381381#[ unstable( feature = "unix_send_signal" , issue = "141975" ) ]
382382pub trait ChildExt : Sealed {
383- fn send_signal ( & mut self , signal : i32 ) -> io:: Result < ( ) > ;
383+ /// Sends a signal to a child process.
384+ ///
385+ /// # Errors
386+ ///
387+ /// This function will return an error if the signal is invalid. The integer values associated
388+ /// with signals are implemenation-specific, so the use of [`libc`] is encouraged.
389+ ///
390+ /// # Examples
391+ ///
392+ /// ```rust
393+ /// #![feature(unix_send_signal)]
394+ ///
395+ /// use std::{io, os::unix::process::ChildExt, process::{Command, Stdio}};
396+ ///
397+ /// use libc::SIGTERM;
398+ ///
399+ /// fn main() -> io::Result<()> {
400+ /// let child = Command::new("cat").stdin(Stdio::piped()).spawn()?;
401+ /// child.send_signal(SIGTERM)?;
402+ /// Ok(())
403+ /// }
404+ /// ```
405+ fn send_signal ( & self , signal : i32 ) -> io:: Result < ( ) > ;
384406}
385407
386408#[ unstable( feature = "unix_send_signal" , issue = "141975" ) ]
387409impl ChildExt for process:: Child {
388- fn send_signal ( & mut self , signal : i32 ) -> io:: Result < ( ) > {
410+ fn send_signal ( & self , signal : i32 ) -> io:: Result < ( ) > {
389411 self . handle . send_signal ( signal)
390412 }
391413}
Original file line number Diff line number Diff line change @@ -967,7 +967,7 @@ impl Process {
967967 self . send_signal ( libc:: SIGKILL )
968968 }
969969
970- pub ( crate ) fn send_signal ( & mut self , signal : i32 ) -> io:: Result < ( ) > {
970+ pub ( crate ) fn send_signal ( & self , signal : i32 ) -> io:: Result < ( ) > {
971971 // If we've already waited on this process then the pid can be recycled
972972 // and used for another process, and we probably shouldn't be signaling
973973 // random processes, so return Ok because the process has exited already.
You can’t perform that action at this time.
0 commit comments