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

Code before:
    ///
    /// to avoid partially moving the `child` and thus blocking yourself from calling
    /// functions on `child` while using `stderr`.
    pub stderr: Option<ChildStderr>,
}

impl Child {
    /// Returns the OS-assigned process identifier associated with this child
    /// while it is still running.
    ///
    /// Once the child has been polled to completion this will return `None`.
    /// This is done to avoid confusion on platforms like Unix where the OS
    /// identifier could be reused once the process has completed.
    pub fn id(&self) -> Option<u32> {
        match &self.child {
            FusedChild::Child(child) => Some(child.inner.id()),
            FusedChild::Done(_) => None,
        }
    }

    #[cfg(windows)]
    #[cfg(tokio_unstable)]
    #[cfg_attr(docsrs, doc(cfg(all(windows, tokio_unstable))))]
        /// Extracts the raw handle of the process associated with this child while
        /// it is still running. Returns `None` if the child has exited.
        pub fn raw_handle(&self) -> Option<RawHandle> {
            match &self.child {
                FusedChild::Child(c) => Some(c.inner.as_raw_handle()),
                FusedChild::Done(_) => None,
            }
        }


    /// Attempts to force the child to exit, but does not wait for the request
    /// to take effect.
    ///
    /// On Unix platforms, this is the equivalent to sending a SIGKILL. Note
    /// that on Unix platforms it is possible for a zombie process to remain
    /// after a kill is sent; to avoid this, the caller should ensure that either
    /// `child.wait().await` or `child.try_wait()` is invoked successfully.
    pub fn start_kill(&mut self) -> io::Result<()> {
        match &mut self.child {
            FusedChild::Child(child) => child.kill(),
            FusedChild::Done(_) => Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                "invalid argument: can't kill an exited process",
            )),
        }
    }

    /// Forces the child to exit.

Review comment (suggestion):
You shouldn't also add it here. As far as I can tell, `as_raw_handle` has been available since Rust 1.2.0, which is older than our minimum supported rust version.

Code after:
    ///
    /// to avoid partially moving the `child` and thus blocking yourself from calling
    /// functions on `child` while using `stderr`.
    pub stderr: Option<ChildStderr>,
}

impl Child {
    /// Returns the OS-assigned process identifier associated with this child
    /// while it is still running.
    ///
    /// Once the child has been polled to completion this will return `None`.
    /// This is done to avoid confusion on platforms like Unix where the OS
    /// identifier could be reused once the process has completed.
    pub fn id(&self) -> Option<u32> {
        match &self.child {
            FusedChild::Child(child) => Some(child.inner.id()),
            FusedChild::Done(_) => None,
        }
    }

    cfg_windows! {
        /// Extracts the raw handle of the process associated with this child while
        /// it is still running. Returns `None` if the child has exited.
        pub fn raw_handle(&self) -> Option<RawHandle> {
            match &self.child {
                FusedChild::Child(c) => Some(c.inner.as_raw_handle()),
                FusedChild::Done(_) => None,
            }
        }
    }

    /// Attempts to force the child to exit, but does not wait for the request
    /// to take effect.
    ///
    /// On Unix platforms, this is the equivalent to sending a SIGKILL. Note
    /// that on Unix platforms it is possible for a zombie process to remain
    /// after a kill is sent; to avoid this, the caller should ensure that either
    /// `child.wait().await` or `child.try_wait()` is invoked successfully.
    pub fn start_kill(&mut self) -> io::Result<()> {
        match &mut self.child {
            FusedChild::Child(child) => child.kill(),
            FusedChild::Done(_) => Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                "invalid argument: can't kill an exited process",
            )),
        }
    }

    /// Forces the child to exit.
    ///
    /// This is equivalent to sending a SIGKILL on unix platforms.