]> git.proxmox.com Git - rustc.git/blob - src/libstd/sys/cloudabi/shims/process.rs
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libstd / sys / cloudabi / shims / process.rs
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.
4 //
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.
10
11 use ffi::OsStr;
12 use fmt;
13 use io;
14 use sys::fs::File;
15 use sys::pipe::AnonPipe;
16 use sys::{unsupported, Void};
17 use sys_common::process::{CommandEnv, DefaultEnvKey};
18
19 ////////////////////////////////////////////////////////////////////////////////
20 // Command
21 ////////////////////////////////////////////////////////////////////////////////
22
23 pub struct Command {
24 env: CommandEnv<DefaultEnvKey>,
25 }
26
27 // passed back to std::process with the pipes connected to the child, if any
28 // were requested
29 pub struct StdioPipes {
30 pub stdin: Option<AnonPipe>,
31 pub stdout: Option<AnonPipe>,
32 pub stderr: Option<AnonPipe>,
33 }
34
35 pub enum Stdio {
36 Inherit,
37 Null,
38 MakePipe,
39 }
40
41 impl Command {
42 pub fn new(_program: &OsStr) -> Command {
43 Command {
44 env: Default::default(),
45 }
46 }
47
48 pub fn arg(&mut self, _arg: &OsStr) {}
49
50 pub fn env_mut(&mut self) -> &mut CommandEnv<DefaultEnvKey> {
51 &mut self.env
52 }
53
54 pub fn cwd(&mut self, _dir: &OsStr) {}
55
56 pub fn stdin(&mut self, _stdin: Stdio) {}
57
58 pub fn stdout(&mut self, _stdout: Stdio) {}
59
60 pub fn stderr(&mut self, _stderr: Stdio) {}
61
62 pub fn spawn(
63 &mut self,
64 _default: Stdio,
65 _needs_stdin: bool,
66 ) -> io::Result<(Process, StdioPipes)> {
67 unsupported()
68 }
69 }
70
71 impl From<AnonPipe> for Stdio {
72 fn from(pipe: AnonPipe) -> Stdio {
73 pipe.diverge()
74 }
75 }
76
77 impl From<File> for Stdio {
78 fn from(file: File) -> Stdio {
79 file.diverge()
80 }
81 }
82
83 impl fmt::Debug for Command {
84 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
85 Ok(())
86 }
87 }
88
89 pub struct ExitStatus(Void);
90
91 impl ExitStatus {
92 pub fn success(&self) -> bool {
93 match self.0 {}
94 }
95
96 pub fn code(&self) -> Option<i32> {
97 match self.0 {}
98 }
99 }
100
101 impl Clone for ExitStatus {
102 fn clone(&self) -> ExitStatus {
103 match self.0 {}
104 }
105 }
106
107 impl Copy for ExitStatus {}
108
109 impl PartialEq for ExitStatus {
110 fn eq(&self, _other: &ExitStatus) -> bool {
111 match self.0 {}
112 }
113 }
114
115 impl Eq for ExitStatus {}
116
117 impl fmt::Debug for ExitStatus {
118 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
119 match self.0 {}
120 }
121 }
122
123 impl fmt::Display for ExitStatus {
124 fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
125 match self.0 {}
126 }
127 }
128
129 pub struct Process(Void);
130
131 impl Process {
132 pub fn id(&self) -> u32 {
133 match self.0 {}
134 }
135
136 pub fn kill(&mut self) -> io::Result<()> {
137 match self.0 {}
138 }
139
140 pub fn wait(&mut self) -> io::Result<ExitStatus> {
141 match self.0 {}
142 }
143
144 pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
145 match self.0 {}
146 }
147 }