mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
exec: timeout on grandchildren
We were enforcing the 10 s wall-clock limit only on the child process. If that child (bash) spawns grandchildren and we kill it on timeout, those grandchildren still have the original stdout/err pipe open, so the background tasks that are draining the pipes block forever
This commit is contained in:
@@ -361,14 +361,13 @@ pub(crate) async fn consume_truncated_output(
|
||||
handle: &mut JoinHandle<std::io::Result<Vec<u8>>>,
|
||||
timeout: Duration,
|
||||
) -> std::io::Result<Vec<u8>> {
|
||||
tokio::select! {
|
||||
join_res = &mut *handle => {
|
||||
match join_res {
|
||||
Ok(io_res) => io_res,
|
||||
Err(join_err) => Err(std::io::Error::other(join_err)),
|
||||
}
|
||||
match tokio::time::timeout(timeout, &mut *handle).await {
|
||||
Ok(join_res) => match join_res {
|
||||
Ok(io_res) => io_res,
|
||||
Err(join_err) => Err(std::io::Error::other(join_err)),
|
||||
},
|
||||
_ = tokio::time::sleep(timeout) => {
|
||||
Err(_elapsed) => {
|
||||
// Timeout: abort the task to avoid hanging on open pipes.
|
||||
handle.abort();
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user