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