Skip to content

Commit 1c2e9fd

Browse files
committed
fix process_lines for sandboxed commands
1 parent 0d3c2f6 commit 1c2e9fd

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/cmd/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ impl<'w, 'pl> Command<'w, 'pl> {
345345
.env("CARGO_HOME", container_dirs::CARGO_HOME.to_str().unwrap())
346346
.env("RUSTUP_HOME", container_dirs::RUSTUP_HOME.to_str().unwrap());
347347

348-
builder.run(workspace, self.timeout, self.no_output_timeout)?;
348+
builder.run(
349+
workspace,
350+
self.timeout,
351+
self.no_output_timeout,
352+
self.process_lines,
353+
)?;
349354
Ok(ProcessOutput {
350355
stdout: Vec::new(),
351356
stderr: Vec::new(),

src/cmd/sandbox.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ impl SandboxBuilder {
262262
workspace: &Workspace,
263263
timeout: Option<Duration>,
264264
no_output_timeout: Option<Duration>,
265+
process_lines: Option<&mut dyn FnMut(&str)>,
265266
) -> Result<(), Error> {
266267
let container = self.create(workspace)?;
267268

@@ -276,7 +277,7 @@ impl SandboxBuilder {
276277
}
277278
}}
278279

279-
container.run(timeout, no_output_timeout)?;
280+
container.run(timeout, no_output_timeout, process_lines)?;
280281
Ok(())
281282
}
282283
}
@@ -323,12 +324,18 @@ impl Container<'_> {
323324
&self,
324325
timeout: Option<Duration>,
325326
no_output_timeout: Option<Duration>,
327+
process_lines: Option<&mut dyn FnMut(&str)>,
326328
) -> Result<(), Error> {
327-
let res = Command::new(self.workspace, "docker")
329+
let mut cmd = Command::new(self.workspace, "docker")
328330
.args(&["start", "-a", &self.id])
329331
.timeout(timeout)
330-
.no_output_timeout(no_output_timeout)
331-
.run();
332+
.no_output_timeout(no_output_timeout);
333+
334+
if let Some(f) = process_lines {
335+
cmd = cmd.process_lines(f);
336+
}
337+
338+
let res = cmd.run();
332339
let details = self.inspect()?;
333340

334341
// Return a different error if the container was killed due to an OOM

0 commit comments

Comments
 (0)