1 // Copyright 2017 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
) {}
50 pub fn env_mut(&mut self) -> &mut CommandEnv
<DefaultEnvKey
> {
54 pub fn cwd(&mut self, _dir
: &OsStr
) {}
56 pub fn stdin(&mut self, _stdin
: Stdio
) {}
58 pub fn stdout(&mut self, _stdout
: Stdio
) {}
60 pub fn stderr(&mut self, _stderr
: Stdio
) {}
66 ) -> io
::Result
<(Process
, StdioPipes
)> {
71 impl From
<AnonPipe
> for Stdio
{
72 fn from(pipe
: AnonPipe
) -> Stdio
{
77 impl From
<File
> for Stdio
{
78 fn from(file
: File
) -> Stdio
{
83 impl fmt
::Debug
for Command
{
84 fn fmt(&self, _f
: &mut fmt
::Formatter
) -> fmt
::Result
{
89 pub struct ExitStatus(Void
);
92 pub fn success(&self) -> bool
{
96 pub fn code(&self) -> Option
<i32> {
101 impl Clone
for ExitStatus
{
102 fn clone(&self) -> ExitStatus
{
107 impl Copy
for ExitStatus {}
109 impl PartialEq
for ExitStatus
{
110 fn eq(&self, _other
: &ExitStatus
) -> bool
{
115 impl Eq
for ExitStatus {}
117 impl fmt
::Debug
for ExitStatus
{
118 fn fmt(&self, _f
: &mut fmt
::Formatter
) -> fmt
::Result
{
123 impl fmt
::Display
for ExitStatus
{
124 fn fmt(&self, _f
: &mut fmt
::Formatter
) -> fmt
::Result
{
129 pub struct Process(Void
);
132 pub fn id(&self) -> u32 {
136 pub fn kill(&mut self) -> io
::Result
<()> {
140 pub fn wait(&mut self) -> io
::Result
<ExitStatus
> {
144 pub fn try_wait(&mut self) -> io
::Result
<Option
<ExitStatus
>> {