mirror of
https://github.com/openai/codex.git
synced 2026-09-03 14:59:03 +00:00
## What changed - Add `--exit-on-stdin-close` and the `CODEX_EXEC_SERVER_EXIT_ON_STDIN_CLOSE` environment variable as opt-in controls for remote exec servers. - Gracefully drain active sessions and processes when the parent closes stdin, then flush telemetry before exiting. - Remove the parent-lifetime environment variable from child process environments. ## Testing - Cover parent disconnects after signal-listener failures. - Exercise remote shutdown end to end, including child termination and final telemetry metrics. - Verify that explicitly disabling the environment variable preserves local exec-server behavior. GitOrigin-RevId: 63063bc097b54684c370bd545cd32d17c4e55d90
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
use std::time::Duration;
|
|
|
|
use super::ShutdownBehavior;
|
|
use super::run_until_shutdown_with_signals;
|
|
|
|
#[tokio::test]
|
|
async fn parent_disconnect_still_stops_executor_after_signal_listener_error() {
|
|
let (parent_sender, parent_receiver) = tokio::sync::oneshot::channel();
|
|
let (shutdown_sender, shutdown_receiver) = tokio::sync::oneshot::channel();
|
|
let run = async move {
|
|
let _ = shutdown_receiver.await;
|
|
Ok::<(), std::io::Error>(())
|
|
};
|
|
let task = tokio::spawn(run_until_shutdown_with_signals(
|
|
run,
|
|
async move {
|
|
let _ = parent_receiver.await;
|
|
},
|
|
std::future::ready(Err(std::io::Error::other("signal listener failed"))),
|
|
ShutdownBehavior::Graceful(shutdown_sender),
|
|
));
|
|
|
|
tokio::task::yield_now().await;
|
|
parent_sender.send(()).expect("parent lifetime receiver");
|
|
|
|
tokio::time::timeout(Duration::from_secs(1), task)
|
|
.await
|
|
.expect("parent disconnect should stop the executor")
|
|
.expect("shutdown task should not panic")
|
|
.expect("executor should shut down successfully");
|
|
}
|