{"record":{"id":"995fc3631260694d","repo":"affaan-m/ECC","slug":"claude-code-did-not-expose-a-process-id","errorCode":null,"errorMessage":"Claude Code did not expose a process id","messagePattern":"Claude Code did not expose a process id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ecc2/src/session/manager.rs","lineNumber":3570,"sourceCode":"        task,\n        session_id,\n        working_dir,\n        None,\n    );\n    let child = command\n        .stdout(Stdio::null())\n        .stderr(Stdio::null())\n        .spawn()\n        .with_context(|| {\n            format!(\n                \"Failed to spawn Claude Code from {}\",\n                agent_program.display()\n            )\n        })?;\n\n    child\n        .id()\n        .ok_or_else(|| anyhow::anyhow!(\"Claude Code did not expose a process id\"))\n}\n\nasync fn stop_session_with_options(\n    db: &StateStore,\n    id: &str,\n    cleanup_worktree: bool,\n) -> Result<()> {\n    let session = resolve_session(db, id)?;\n    stop_session_recorded(db, &session, cleanup_worktree)\n}\n\nfn stop_session_recorded(db: &StateStore, session: &Session, cleanup_worktree: bool) -> Result<()> {\n    if let Some(pid) = session.pid {\n        kill_process(pid)?;\n    }\n\n    db.update_pid(&session.id, None)?;\n    db.update_state(&session.id, &SessionState::Stopped)?;","sourceCodeStart":3552,"sourceCodeEnd":3588,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/session/manager.rs#L3552-L3588","documentation":"Same family as the runner-pid error but for the Claude Code agent process: child.id() returned None after spawning the agent binary. The manager needs the pid to stop/track the session, so None is converted into an anyhow error.","triggerScenarios":"Spawning the Claude Code agent executable where the Child handle's id() is None — the process already exited, or platform-specific pid exposure failed (notably Windows).","commonSituations":"agent_program path pointing at a wrapper that exits immediately; missing agent binary permissions causing instant death; Windows handle/AV interference.","solutions":["Verify agent_program exists and is executable before spawn","Run the agent manually with the same args to see why it exits instantly","Capture the spawn exit status and surface it instead of only the missing pid"],"exampleFix":"// before\nchild.id().ok_or_else(|| anyhow::anyhow!(\"Claude Code did not expose a process id\"))\n// after\nlet pid = child.id().with_context(|| format!(\"Claude Code exited immediately: {:?}\", child.try_wait()))?;","handlingStrategy":"try-catch","validationCode":"if !agent_program.exists() {\n    anyhow::bail!(\"agent binary not found: {}\", agent_program.display());\n}","typeGuard":null,"tryCatchPattern":"match spawn_agent().await {\n    Ok(pid) => /* track session */,\n    Err(e) if e.to_string().contains(\"did not expose a process id\") => {\n        eprintln!(\"Claude Code exited immediately; run it manually to see the error\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Smoke-test the agent command line outside the manager first","Check binary permissions/executable bit","Verify PATH/auth so the agent doesn't die at startup"],"tags":["rust","process","spawn","pid","claude-code"],"backgroundTag":"process-pid-unavailable","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}