codex: fix rmcp pid-file race (#13593)

This commit is contained in:
Ahmed Ibrahim
2026-03-06 21:15:48 -08:00
parent 12c68ddc19
commit 518c9a7ccf

View File

@@ -24,8 +24,13 @@ async fn wait_for_pid_file(path: &Path) -> Result<u32> {
for _ in 0..50 {
match fs::read_to_string(path) {
Ok(content) => {
let pid = content
.trim()
let trimmed = content.trim();
if trimmed.is_empty() {
tokio::time::sleep(Duration::from_millis(100)).await;
continue;
}
let pid = trimmed
.parse::<u32>()
.with_context(|| format!("failed to parse pid from {}", path.display()))?;
return Ok(pid);