mirror of
https://github.com/openai/codex.git
synced 2026-09-20 12:47:38 +00:00
## What changed Expose the shared `Child` type and `spawn_child` function from `codex-utils-pty`, and update the MCP stdio transport to use them. Move the existing macOS spawning implementation and its tests into the utility crate, preserving platform-specific spawning, piped stdio, and kill-on-drop behavior. GitOrigin-RevId: 26c2fb2f22cdba907aa9d18cab7dc8c4ac1c909e
35 lines
850 B
Rust
35 lines
850 B
Rust
//! Uniform child-process API for local subprocesses, with platform-specific spawning.
|
|
//!
|
|
//! Commands must use the launcher's cleared environment, process group, and default
|
|
//! argv[0]. Both implementations expose Tokio stdio handles and kill on drop.
|
|
|
|
use std::io;
|
|
use std::process::Stdio;
|
|
|
|
use tokio::process::Command;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
#[path = "macos_child.rs"]
|
|
mod macos;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
pub use macos::Child;
|
|
#[cfg(not(target_os = "macos"))]
|
|
pub use tokio::process::Child;
|
|
|
|
pub fn spawn(mut command: Command) -> io::Result<Child> {
|
|
command
|
|
.kill_on_drop(true)
|
|
.stdin(Stdio::piped())
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped());
|
|
#[cfg(target_os = "macos")]
|
|
{
|
|
Child::spawn(command)
|
|
}
|
|
#[cfg(not(target_os = "macos"))]
|
|
{
|
|
command.spawn()
|
|
}
|
|
}
|