Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ impl AsInner<imp::Process> for Child {
}
}

impl FromInner<(imp::Process, imp::StdioPipes)> for Child {
fn from_inner((handle, io): (imp::Process, imp::StdioPipes)) -> Child {
impl FromInner<(imp::Process, StdioPipes)> for Child {
fn from_inner((handle, io): (imp::Process, StdioPipes)) -> Child {
Child {
handle,
stdin: io.stdin.map(ChildStdin::from_inner),
Expand All @@ -296,6 +296,15 @@ impl fmt::Debug for Child {
}
}

/// The pipes connected to a spawned process.
///
/// Used to pass pipe handles between this module and [`imp`].
pub(crate) struct StdioPipes {
pub stdin: Option<AnonPipe>,
pub stdout: Option<AnonPipe>,
pub stderr: Option<AnonPipe>,
}

/// A handle to a child process's standard input (stdin).
///
/// This struct is used in the [`stdin`] field on [`Child`].
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod env;

pub use env::CommandEnvs;
pub use imp::{
Command, CommandArgs, EnvKey, ExitCode, ExitStatus, ExitStatusError, Process, Stdio, StdioPipes,
Command, CommandArgs, EnvKey, ExitCode, ExitStatus, ExitStatusError, Process, Stdio,
};

#[cfg(any(
Expand Down
9 changes: 1 addition & 8 deletions library/std/src/sys/process/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub use crate::ffi::OsString as EnvKey;
use crate::ffi::{OsStr, OsString};
use crate::num::{NonZero, NonZeroI32};
use crate::path::Path;
use crate::process::StdioPipes;
use crate::sys::fs::File;
use crate::sys::pal::helpers;
use crate::sys::pal::os::error_string;
Expand All @@ -27,14 +28,6 @@ pub struct Command {
env: CommandEnv,
}

// passed back to std::process with the pipes connected to the child, if any
// were requested
pub struct StdioPipes {
pub stdin: Option<AnonPipe>,
pub stdout: Option<AnonPipe>,
pub stderr: Option<AnonPipe>,
}

#[derive(Copy, Clone, Debug)]
pub enum Stdio {
Inherit,
Expand Down
9 changes: 1 addition & 8 deletions library/std/src/sys/process/unix/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::collections::BTreeMap;
use crate::ffi::{CStr, CString, OsStr, OsString};
use crate::os::unix::prelude::*;
use crate::path::Path;
use crate::process::StdioPipes;
use crate::sys::fd::FileDesc;
use crate::sys::fs::File;
#[cfg(not(target_os = "fuchsia"))]
Expand Down Expand Up @@ -104,14 +105,6 @@ pub struct Command {
setsid: bool,
}

// passed back to std::process with the pipes connected to the child, if any
// were requested
pub struct StdioPipes {
pub stdin: Option<AnonPipe>,
pub stdout: Option<AnonPipe>,
pub stderr: Option<AnonPipe>,
}

// passed to do_exec() with configuration of what the child stdio should look
// like
#[cfg_attr(target_os = "vita", allow(dead_code))]
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/process/unix/fuchsia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use libc::{c_int, size_t};

use super::common::*;
use crate::num::NonZero;
use crate::process::StdioPipes;
use crate::sys::pal::fuchsia::*;
use crate::{fmt, io, mem, ptr};

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/process/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ cfg_select! {

pub use imp::{ExitStatus, ExitStatusError, Process};

pub use self::common::{Command, CommandArgs, ExitCode, Stdio, StdioPipes};
pub use self::common::{Command, CommandArgs, ExitCode, Stdio};
pub use crate::ffi::OsString as EnvKey;
1 change: 1 addition & 0 deletions library/std/src/sys/process/unix/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use libc::{gid_t, uid_t};
use super::common::*;
use crate::io::{self, Error, ErrorKind};
use crate::num::NonZero;
use crate::process::StdioPipes;
use crate::sys::cvt;
#[cfg(target_os = "linux")]
use crate::sys::pal::linux::pidfd::PidFd;
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/process/unix/unsupported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use libc::{c_int, pid_t};
use super::common::*;
use crate::io;
use crate::num::NonZero;
use crate::process::StdioPipes;
use crate::sys::pal::unsupported::*;

////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/process/unix/vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use libc::{self, RTP_ID, c_char, c_int};
use super::common::*;
use crate::io::{self, ErrorKind};
use crate::num::NonZero;
use crate::process::StdioPipes;
use crate::sys::{cvt, thread};
use crate::{fmt, sys};

Expand Down
9 changes: 1 addition & 8 deletions library/std/src/sys/process/unsupported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pub use crate::ffi::OsString as EnvKey;
use crate::ffi::{OsStr, OsString};
use crate::num::NonZero;
use crate::path::Path;
use crate::process::StdioPipes;
use crate::sys::fs::File;
use crate::sys::pipe::AnonPipe;
use crate::sys::unsupported;
Expand All @@ -23,14 +24,6 @@ pub struct Command {
stderr: Option<Stdio>,
}

// passed back to std::process with the pipes connected to the child, if any
// were requested
pub struct StdioPipes {
pub stdin: Option<AnonPipe>,
pub stdout: Option<AnonPipe>,
pub stderr: Option<AnonPipe>,
}

#[derive(Debug)]
pub enum Stdio {
Inherit,
Expand Down
7 changes: 1 addition & 6 deletions library/std/src/sys/process/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::os::windows::ffi::{OsStrExt, OsStringExt};
use crate::os::windows::io::{AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle};
use crate::os::windows::process::ProcThreadAttributeList;
use crate::path::{Path, PathBuf};
use crate::process::StdioPipes;
use crate::sync::Mutex;
use crate::sys::args::{self, Arg};
use crate::sys::c::{self, EXIT_FAILURE, EXIT_SUCCESS};
Expand Down Expand Up @@ -169,12 +170,6 @@ pub enum Stdio {
Handle(Handle),
}

pub struct StdioPipes {
pub stdin: Option<AnonPipe>,
pub stdout: Option<AnonPipe>,
pub stderr: Option<AnonPipe>,
}

impl Command {
pub fn new(program: &OsStr) -> Command {
Command {
Expand Down
Loading