mirror of
https://github.com/openai/codex.git
synced 2026-11-25 23:30:49 +00:00
Publish process exit status and exit code together (#63896)
## Why Separate reads and writes of the exit flag and exit code could let unified exec observe a process as exited before seeing its exit code, or return a live session ID alongside an exit code. ## What changed Store the exit code in a shared `OnceLock` for pipe, PTY, and driver-backed processes. Derive `has_exited()` from the presence of that code. Unified exec reads the code when it retires the session, after any pending output it needs to retain has been drained. ## Testing Extend the pipe, PTY, and driver-backed tests to check that the process handle exposes the exit code reported by the exit notification. The driver-backed test also verifies that output arriving after the notification is still collected. GitOrigin-RevId: 6192e5ceb9c71c6321e76f750c531c0ea6554dca
This commit is contained in:
@@ -713,11 +713,7 @@ impl UnifiedExecProcessManager {
|
||||
.refresh_process_state(process_id, &process, retention)
|
||||
.await
|
||||
{
|
||||
ProcessStatus::Alive {
|
||||
exit_code,
|
||||
process_id,
|
||||
..
|
||||
} => (Some(process_id), exit_code),
|
||||
ProcessStatus::Alive { process_id, .. } => (Some(process_id), None),
|
||||
ProcessStatus::Exited { exit_code, entry } => {
|
||||
entry.process.cancellation_token().cancel();
|
||||
if let Err(message) = finish_deferred_network_approval_after_process_exit(
|
||||
@@ -1054,10 +1050,9 @@ impl UnifiedExecProcessManager {
|
||||
.await;
|
||||
let (process_id, exit_code, event_call_id) = match status {
|
||||
ProcessStatus::Alive {
|
||||
exit_code,
|
||||
call_id,
|
||||
process_id,
|
||||
} => (Some(process_id), exit_code, call_id),
|
||||
} => (Some(process_id), None, call_id),
|
||||
ProcessStatus::Exited { exit_code, entry } => {
|
||||
entry.process.cancellation_token().cancel();
|
||||
let call_id = entry.call_id.clone();
|
||||
@@ -1126,7 +1121,6 @@ impl UnifiedExecProcessManager {
|
||||
return ProcessStatus::Unknown;
|
||||
};
|
||||
|
||||
let exit_code = entry.process.exit_code();
|
||||
let process_id = entry.process_id;
|
||||
|
||||
if entry.process.has_exited() {
|
||||
@@ -1143,7 +1137,6 @@ impl UnifiedExecProcessManager {
|
||||
.map_or(true, |buffer| buffer.pending.total_bytes() > 0))
|
||||
{
|
||||
return ProcessStatus::Alive {
|
||||
exit_code: None,
|
||||
call_id: entry.call_id.clone(),
|
||||
process_id,
|
||||
};
|
||||
@@ -1152,12 +1145,11 @@ impl UnifiedExecProcessManager {
|
||||
return ProcessStatus::Unknown;
|
||||
};
|
||||
ProcessStatus::Exited {
|
||||
exit_code,
|
||||
exit_code: entry.process.exit_code(),
|
||||
entry: Box::new(entry),
|
||||
}
|
||||
} else {
|
||||
ProcessStatus::Alive {
|
||||
exit_code,
|
||||
call_id: entry.call_id.clone(),
|
||||
process_id,
|
||||
}
|
||||
@@ -1818,7 +1810,6 @@ enum OutputRetention {
|
||||
|
||||
enum ProcessStatus {
|
||||
Alive {
|
||||
exit_code: Option<i32>,
|
||||
call_id: String,
|
||||
process_id: i32,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user