uefi: process Implement inherit · model-checking/verify-rust-std@1991fe3 (original) (raw)
`@@ -23,8 +23,8 @@ use super::helpers;
`
23
23
``
24
24
`pub struct Command {
`
25
25
`prog: OsString,
`
26
``
`-
stdout: Option<uefi_command_internal::PipeProtocol>,
`
27
``
`-
stderr: Option<uefi_command_internal::PipeProtocol>,
`
``
26
`+
stdout: Option,
`
``
27
`+
stderr: Option,
`
28
28
`}
`
29
29
``
30
30
`// passed back to std::process with the pipes connected to the child, if any
`
`@@ -65,19 +65,11 @@ impl Command {
`
65
65
`}
`
66
66
``
67
67
`pub fn stdout(&mut self, stdout: Stdio) {
`
68
``
`-
self.stdout = match stdout {
`
69
``
`-
Stdio::MakePipe => Some(uefi_command_internal::PipeProtocol::new()),
`
70
``
`-
Stdio::Null => Some(uefi_command_internal::PipeProtocol::null()),
`
71
``
`-
_ => None,
`
72
``
`-
};
`
``
68
`+
self.stdout = Some(stdout);
`
73
69
`}
`
74
70
``
75
71
`pub fn stderr(&mut self, stderr: Stdio) {
`
76
``
`-
self.stderr = match stderr {
`
77
``
`-
Stdio::MakePipe => Some(uefi_command_internal::PipeProtocol::new()),
`
78
``
`-
Stdio::Null => Some(uefi_command_internal::PipeProtocol::null()),
`
79
``
`-
_ => None,
`
80
``
`-
};
`
``
72
`+
self.stderr = Some(stderr);
`
81
73
`}
`
82
74
``
83
75
`pub fn get_program(&self) -> &OsStr {
`
`@@ -104,31 +96,56 @@ impl Command {
`
104
96
`unsupported()
`
105
97
`}
`
106
98
``
``
99
`+
fn create_pipe(
`
``
100
`+
s: Stdio,
`
``
101
`+
) -> io::Result<Option<helpers::Protocol<uefi_command_internal::PipeProtocol>>> {
`
``
102
`+
match s {
`
``
103
`+
Stdio::MakePipe => helpers::Protocol::create(
`
``
104
`+
uefi_command_internal::PipeProtocol::new(),
`
``
105
`+
simple_text_output::PROTOCOL_GUID,
`
``
106
`+
)
`
``
107
`+
.map(Some),
`
``
108
`+
Stdio::Null => helpers::Protocol::create(
`
``
109
`+
uefi_command_internal::PipeProtocol::null(),
`
``
110
`+
simple_text_output::PROTOCOL_GUID,
`
``
111
`+
)
`
``
112
`+
.map(Some),
`
``
113
`+
Stdio::Inherit => Ok(None),
`
``
114
`+
}
`
``
115
`+
}
`
``
116
+
107
117
`pub fn output(&mut self) -> io::Result<(ExitStatus, Vec, Vec)> {
`
108
118
`let mut cmd = uefi_command_internal::Command::load_image(&self.prog)?;
`
109
119
``
110
``
`-
let stdout: helpers::Protocol<uefi_command_internal::PipeProtocol> =
`
``
120
`+
let stdout: Option<helpers::Protocol<uefi_command_internal::PipeProtocol>> =
`
111
121
`match self.stdout.take() {
`
112
``
`-
Some(s) => helpers::Protocol::create(s, simple_text_output::PROTOCOL_GUID),
`
``
122
`+
Some(s) => Self::create_pipe(s),
`
113
123
`None => helpers::Protocol::create(
`
114
124
` uefi_command_internal::PipeProtocol::new(),
`
115
125
` simple_text_output::PROTOCOL_GUID,
`
116
``
`-
),
`
``
126
`+
)
`
``
127
`+
.map(Some),
`
117
128
`}?;
`
118
129
``
119
``
`-
let stderr: helpers::Protocol<uefi_command_internal::PipeProtocol> =
`
``
130
`+
let stderr: Option<helpers::Protocol<uefi_command_internal::PipeProtocol>> =
`
120
131
`match self.stderr.take() {
`
121
``
`-
Some(s) => helpers::Protocol::create(s, simple_text_output::PROTOCOL_GUID),
`
``
132
`+
Some(s) => Self::create_pipe(s),
`
122
133
`None => helpers::Protocol::create(
`
123
134
` uefi_command_internal::PipeProtocol::new(),
`
124
135
` simple_text_output::PROTOCOL_GUID,
`
125
``
`-
),
`
``
136
`+
)
`
``
137
`+
.map(Some),
`
126
138
`}?;
`
127
139
``
128
``
`-
cmd.stdout_init(stdout)?;
`
129
``
`-
cmd.stderr_init(stderr)?;
`
``
140
`+
if let Some(stdout) = stdout {
`
``
141
`+
cmd.stdout_init(stdout)?;
`
``
142
`+
}
`
``
143
`+
if let Some(stderr) = stderr {
`
``
144
`+
cmd.stderr_init(stderr)?;
`
``
145
`+
}
`
130
146
``
131
147
`let stat = cmd.start_image()?;
`
``
148
+
132
149
`let stdout = cmd.stdout()?;
`
133
150
`let stderr = cmd.stderr()?;
`
134
151
``