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

process: stabilize Command::process_group #6731

Merged
merged 1 commit into from
Jul 27, 2024
Merged
Changes from all commits
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: 18 additions & 13 deletions tokio/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,29 +751,34 @@ impl Command {
///
/// Process groups determine which processes receive signals.
///
/// **Note**: This is an [unstable API][unstable] but will be stabilised once
/// tokio's `MSRV` is sufficiently new. See [the documentation on
/// unstable features][unstable] for details about using unstable features.
/// # 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.
///
/// If you want similar behavior without using this unstable feature you can
/// create a [`std::process::Command`] and convert that into a
/// [`tokio::process::Command`] using the `From` trait.
/// The parent process could install a [signal handler] and manage the
/// process on its own terms.
///
/// [unstable]: crate#unstable-features
/// [`tokio::process::Command`]: crate::process::Command
/// A process group ID of 0 will use the process ID as the PGID.
///
/// ```no_run
/// # async fn test() { // allow using await
/// use tokio::process::Command;
///
/// let output = Command::new("ls")
/// .process_group(0)
/// .output().await.unwrap();
/// let output = Command::new("sleep")
/// .arg("10")
/// .process_group(0)
/// .output()
/// .await
/// .unwrap();
/// # }
/// ```
///
/// [signal handler]: crate::signal
#[cfg(unix)]
#[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(all(unix, tokio_unstable))))]
#[cfg_attr(docsrs, doc(cfg(unix)))]
pub fn process_group(&mut self, pgroup: i32) -> &mut Command {
self.std.process_group(pgroup);
self
Expand Down
Loading