Hmbown/CodeWhale · error · anyhow::Error

foreground shell did not return a process id

Error message

foreground shell did not return a process id

What it means

Type guard on the spawn result: the spawn call succeeded but spawned.task_id was None, meaning the foreground shell spawn path returned a handle without a process id. Foreground execution requires a pid for lifecycle management, so the Option is converted into this error via ok_or_else.

Source

Thrown at crates/tui/src/tools/shell.rs:4045

            command,
            working_dir.as_deref(),
            spawn_timeout_ms,
            true,
            stdin_data,
            tty,
            policy_override,
            extra_env,
            owner,
            context.state_namespace.clone(),
            lifecycle,
            direct_argv.then_some(context.workspace.as_path()),
            false,
            timeout_bounds_ms,
        )?
    };
    let task_id = spawned
        .task_id
        .ok_or_else(|| anyhow!("foreground shell did not return a process id"))?;
    if let Some(permit) = heavy_permit {
        let mut manager = context
            .shell_manager
            .lock()
            .map_err(|_| anyhow!("shell manager lock poisoned"))?;
        manager.attach_heavy_permit(&task_id, permit)?;
    }

    if stdin_data.is_some() {
        let mut manager = context
            .shell_manager
            .lock()
            .map_err(|_| anyhow!("shell manager lock poisoned"))?;
        manager.write_stdin(&task_id, "", true)?;
    }

    let deadline = timeout_ms.map(|timeout| Instant::now() + Duration::from_millis(timeout));
    loop {

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Check shell manager logs — the spawn half-completed, which may indicate a race with process reaping
  2. Retry the command; a missing pid on a foreground spawn is not a durable condition
  3. Report if reproducible: the spawn backend should always attach a pid for foreground runs
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/tui/src/tools/shell.rs:4045 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/5a6efcbc8921dab4. Report an issue: GitHub.