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 {
380
380
381
381
#[ unstable( feature = "unix_send_signal" , issue = "141975" ) ]
382
382
pub 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 < ( ) > ;
384
406
}
385
407
386
408
#[ unstable( feature = "unix_send_signal" , issue = "141975" ) ]
387
409
impl ChildExt for process:: Child {
388
- fn send_signal ( & mut self , signal : i32 ) -> io:: Result < ( ) > {
410
+ fn send_signal ( & self , signal : i32 ) -> io:: Result < ( ) > {
389
411
self . handle . send_signal ( signal)
390
412
}
391
413
}
Original file line number Diff line number Diff line change @@ -967,7 +967,7 @@ impl Process {
967
967
self . send_signal ( libc:: SIGKILL )
968
968
}
969
969
970
- pub ( crate ) fn send_signal ( & mut self , signal : i32 ) -> io:: Result < ( ) > {
970
+ pub ( crate ) fn send_signal ( & self , signal : i32 ) -> io:: Result < ( ) > {
971
971
// If we've already waited on this process then the pid can be recycled
972
972
// and used for another process, and we probably shouldn't be signaling
973
973
// random processes, so return Ok because the process has exited already.
You can’t perform that action at this time.
0 commit comments