Skip to content

Commit

Permalink
Rollup merge of rust-lang#99088 - niklasf:stabilize-process_set_proce…
Browse files Browse the repository at this point in the history
…ss_group, r=joshtriplett

Document and stabilize process_set_process_group

Tracking issue: rust-lang#93857

FCP finished here: rust-lang#93857 (comment)
  • Loading branch information
JohnTitor committed Jul 17, 2022
2 parents 0748638 + 629b0b4 commit f49d267
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions library/std/src/os/unix/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f49d267

Please sign in to comment.