process: stabilize Command::process_group (#6731)

This commit is contained in:
Niklas Fiekas
2024-07-27 23:08:40 +02:00
committed by GitHub
parent f602eae499
commit ebda4c3d3f
+18 -13
View File
@@ -751,29 +751,34 @@ impl Command {
/// ///
/// Process groups determine which processes receive signals. /// Process groups determine which processes receive signals.
/// ///
/// **Note**: This is an [unstable API][unstable] but will be stabilised once /// # Examples
/// tokio's `MSRV` is sufficiently new. See [the documentation on
/// unstable features][unstable] for details about using unstable features.
/// ///
/// If you want similar behavior without using this unstable feature you can /// Pressing Ctrl-C in a terminal will send `SIGINT` to all processes
/// create a [`std::process::Command`] and convert that into a /// in the current foreground process group. By spawning the `sleep`
/// [`tokio::process::Command`] using the `From` trait. /// subprocess in a new process group, it will not receive `SIGINT`
/// from the terminal.
/// ///
/// [unstable]: crate#unstable-features /// The parent process could install a [signal handler] and manage the
/// [`tokio::process::Command`]: crate::process::Command /// process on its own terms.
///
/// A process group ID of 0 will use the process ID as the PGID.
/// ///
/// ```no_run /// ```no_run
/// # async fn test() { // allow using await /// # async fn test() { // allow using await
/// use tokio::process::Command; /// use tokio::process::Command;
/// ///
/// let output = Command::new("ls") /// let output = Command::new("sleep")
/// .process_group(0) /// .arg("10")
/// .output().await.unwrap(); /// .process_group(0)
/// .output()
/// .await
/// .unwrap();
/// # } /// # }
/// ``` /// ```
///
/// [signal handler]: crate::signal
#[cfg(unix)] #[cfg(unix)]
#[cfg(tokio_unstable)] #[cfg_attr(docsrs, doc(cfg(unix)))]
#[cfg_attr(docsrs, doc(cfg(all(unix, tokio_unstable))))]
pub fn process_group(&mut self, pgroup: i32) -> &mut Command { pub fn process_group(&mut self, pgroup: i32) -> &mut Command {
self.std.process_group(pgroup); self.std.process_group(pgroup);
self self