Skip to content

Commit 0103b4c

Browse files
committed
Make the 10 MB bash output cap fire for commands that finish quickly, instead of returning a silently truncated success
1 parent 9e22548 commit 0103b4c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/tools/bash/executor.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,18 @@ impl BashExecutor {
313313
let _ = stdout_handle.join();
314314
let _ = stderr_handle.join();
315315

316+
// Readers drain the pipe to EOF, so the overflow flag now
317+
// reflects the full output. Recheck because a child that
318+
// exits faster than one supervisor tick breaks the loop via
319+
// try_wait before the in-loop overflow check has run.
320+
if termination.is_none() {
321+
if stdout_overflow.load(Ordering::SeqCst) {
322+
termination = Some(TerminationReason::StdoutCapExceeded);
323+
} else if stderr_overflow.load(Ordering::SeqCst) {
324+
termination = Some(TerminationReason::StderrCapExceeded);
325+
}
326+
}
327+
316328
if let Some(e) = try_wait_error {
317329
return Err(SofosError::ToolExecution(format!(
318330
"Failed to wait on command: {}",

0 commit comments

Comments
 (0)