Skip to content
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

Document and stabilize process_set_process_group #99088

Merged
merged 2 commits into from
Jul 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 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,34 @@ 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 of the child process. Equivalent to a
joshtriplett marked this conversation as resolved.
Show resolved Hide resolved
/// `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.
///
joshtriplett marked this conversation as resolved.
Show resolved Hide resolved
/// ```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