Repository: tokio-rs/tokio
File: tokio/src/process/mod.rs (Rust)

Code before:
    /// This is often a very constrained environment where normal operations
    /// like `malloc` or acquiring a mutex are not guaranteed to work (due to
    /// other threads perhaps still running when the `fork` was run).
    ///
    /// This also means that all resources such as file descriptors and
    /// memory-mapped regions got duplicated. It is your responsibility to make
    /// sure that the closure does not violate library invariants by making
    /// invalid use of these duplicates.
    ///
    /// When this closure is run, aspects such as the stdio file descriptors and
    /// working directory have successfully been changed, so output to these
    /// locations may not appear where intended.
    #[cfg(unix)]
    #[cfg_attr(docsrs, doc(cfg(unix)))]
    pub unsafe fn pre_exec<F>(&mut self, f: F) -> &mut Command
    where
        F: FnMut() -> io::Result<()> + Send + Sync + 'static,
    {
        self.std.pre_exec(f);
        self
    }

    /// 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.
    ///
    /// ```no_run
    /// use tokio::process::Command;
    ///
    /// Command::new("ls")
    ///     .process_group(0)
    ///     .spawn()?
    ///     .wait()
    ///     .await?;
    /// ```
    #[cfg(unix)]
    #[cfg_attr(docsrs, doc(cfg(unix)))]
    #[cfg(tokio_unstable)]
    pub fn process_group(&mut self, pgroup: i32) -> &mut Command {
        self.std.process_group(pgroup);
        self
    }

    /// Executes the command as a child process, returning a handle to it.
    ///
    /// By default, stdin, stdout and stderr are inherited from the parent.
    ///
    /// This method will spawn the child process synchronously and return a
    /// handle to a future-aware child process. The `Child` returned implements
    /// `Future` itself to acquire the `ExitStatus` of the child, and otherwise

Review comment (suggestion):
This should document that it is unstable, how to enable unstable features (a link is fine - see doc for other unstable methods), and that it will become stable when our MSRV is new enough to allow this in a stable manner. It would also be nice to mention that you can do this today by constructing an `std::process::Command` and using our `From` impl to convert it.

Code after:
    /// This is often a very constrained environment where normal operations
    /// like `malloc` or acquiring a mutex are not guaranteed to work (due to
    /// other threads perhaps still running when the `fork` was run).
    ///
    /// This also means that all resources such as file descriptors and
    /// memory-mapped regions got duplicated. It is your responsibility to make
    /// sure that the closure does not violate library invariants by making
    /// invalid use of these duplicates.
    ///
    /// When this closure is run, aspects such as the stdio file descriptors and
    /// working directory have successfully been changed, so output to these
    /// locations may not appear where intended.
    #[cfg(unix)]
    #[cfg_attr(docsrs, doc(cfg(unix)))]
    pub unsafe fn pre_exec<F>(&mut self, f: F) -> &mut Command
    where
        F: FnMut() -> io::Result<()> + Send + Sync + 'static,
    {
        self.std.pre_exec(f);
        self
    }

    /// 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.
    ///
    /// **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.
    ///
    /// If you want similar behaviour without using this unstable feature you can
    /// create a [`std::process::Command`] and convert that into a
    /// [`tokio::process::Command`] using the `From` trait.
    ///
    /// [unstable]: crate#unstable-features
    /// [`tokio::process::Command`]: crate::process::Command
    ///
    /// ```no_run
    /// use tokio::process::Command;
    ///
    /// let command = Command::new("ls")
    ///         .process_group(0);
    /// ```
    #[cfg(unix)]
    #[cfg(tokio_unstable)]
    #[cfg_attr(docsrs, doc(cfg(all(unix, tokio_unstable))))]
    pub fn process_group(&mut self, pgroup: i32) -> &mut Command {
        self.std.process_group(pgroup);
        self
    }