1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
15 use sys::pipe::AnonPipe;
16 use sys::{unsupported, Void};
17 use sys_common::process::{CommandEnv, DefaultEnvKey};
19 ////////////////////////////////////////////////////////////////////////////////
21 ////////////////////////////////////////////////////////////////////////////////
24 env: CommandEnv<DefaultEnvKey>
27 // passed back to std::process with the pipes connected to the child, if any
29 pub struct StdioPipes {
30 pub stdin: Option<AnonPipe>,
31 pub stdout: Option<AnonPipe>,
32 pub stderr: Option<AnonPipe>,
42 pub fn new(_program: &OsStr) -> Command {
44 env: Default::default()
48 pub fn arg(&mut self, _arg: &OsStr) {
51 pub fn env_mut(&mut self) -> &mut CommandEnv<DefaultEnvKey> {
55 pub fn cwd(&mut self, _dir: &OsStr) {
58 pub fn stdin(&mut self, _stdin: Stdio) {
61 pub fn stdout(&mut self, _stdout: Stdio) {
64 pub fn stderr(&mut self, _stderr: Stdio) {
67 pub fn spawn(&mut self, _default: Stdio, _needs_stdin: bool)
68 -> io::Result<(Process, StdioPipes)> {
73 impl From<AnonPipe> for Stdio {
74 fn from(pipe: AnonPipe) -> Stdio {
79 impl From<File> for Stdio {
80 fn from(file: File) -> Stdio {
85 impl fmt::Debug for Command {
86 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
91 pub struct ExitStatus(Void);
94 pub fn success(&self) -> bool {
98 pub fn code(&self) -> Option<i32> {
103 impl Clone for ExitStatus {
104 fn clone(&self) -> ExitStatus {
109 impl Copy for ExitStatus {}
111 impl PartialEq for ExitStatus {
112 fn eq(&self, _other: &ExitStatus) -> bool {
117 impl Eq for ExitStatus {
120 impl fmt::Debug for ExitStatus {
121 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
126 impl fmt::Display for ExitStatus {
127 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
132 #[derive(PartialEq, Eq, Clone, Copy, Debug)]
133 pub struct ExitCode(bool);
136 pub const SUCCESS: ExitCode = ExitCode(false);
137 pub const FAILURE: ExitCode = ExitCode(true);
139 pub fn as_i32(&self) -> i32 {
144 pub struct Process(Void);
147 pub fn id(&self) -> u32 {
151 pub fn kill(&mut self) -> io::Result<()> {
155 pub fn wait(&mut self) -> io::Result<ExitStatus> {
159 pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {