diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-07-17 13:08:50 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-17 13:08:50 +0900 |
| commit | f49d2671365f1b9d66815c414d498fcff76fda82 (patch) | |
| tree | b3faf4304261873679063374e714ee7d790c7ee0 | |
| parent | 0748638cf9483ac218b374c81ac7b1e875758f74 (diff) | |
| parent | 629b0b488b3e84ce389c71a10ca3ca976bf05d92 (diff) | |
| download | rust-f49d2671365f1b9d66815c414d498fcff76fda82.tar.gz rust-f49d2671365f1b9d66815c414d498fcff76fda82.zip | |
Rollup merge of #99088 - niklasf:stabilize-process_set_process_group, r=joshtriplett
Document and stabilize process_set_process_group Tracking issue: https://github.com/rust-lang/rust/issues/93857 FCP finished here: https://github.com/rust-lang/rust/issues/93857#issuecomment-1179551697
| -rw-r--r-- | library/std/src/os/unix/process.rs | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/library/std/src/os/unix/process.rs b/library/std/src/os/unix/process.rs index 5065530e8d4..09b2bfe39f0 100644 --- a/library/std/src/os/unix/process.rs +++ b/library/std/src/os/unix/process.rs @@ -148,9 +148,36 @@ pub trait CommandExt: Sealed { where S: AsRef<OsStr>; - /// Sets the process group ID of the child process. Translates to a `setpgid` call in the child - /// process. - #[unstable(feature = "process_set_process_group", issue = "93857")] + /// Sets the process group ID (PGID) of the child process. Equivalent to a + /// `setpgid` call in the child process, but may be more efficient. + /// + /// Process groups determine which processes receive signals. + /// + /// # Examples + /// + /// Pressing Ctrl-C in a terminal will send SIGINT to all processes in + /// the current foreground process group. By spawning the `sleep` + /// subprocess in a new process group, it will not receive SIGINT from the + /// terminal. + /// + /// The parent process could install a signal handler and manage the + /// subprocess on its own terms. + /// + /// A process group ID of 0 will use the process ID as the PGID. + /// + /// ```no_run + /// use std::process::Command; + /// use std::os::unix::process::CommandExt; + /// + /// Command::new("sleep") + /// .arg("10") + /// .process_group(0) + /// .spawn()? + /// .wait()?; + /// # + /// # Ok::<_, Box<dyn std::error::Error>>(()) + /// ``` + #[stable(feature = "process_set_process_group", since = "1.64.0")] fn process_group(&mut self, pgroup: i32) -> &mut process::Command; } |
