Hmbown/CodeWhale · error
Persistent service has no process group id
Error message
Persistent service has no process group id
What it means
During background-shell spawn, when the job was requested as a pending persistent service (persist_pending, unix only), the manager must register the child's OS process id as a persistent process group so it survives and can be reaped later. If ShellChild::process_id() returns None — the child handle does not expose a pid at that point — the spawn fails with this error rather than registering a bogus group.
Solutions
- Re-run the persistent-service command; transient spawn races usually succeed on retry.
- Check whether the command runs under a sandbox or PTY wrapper that does not expose a pid; run it as a normal background job instead of a persistent service.
- If it reproduces every time, inspect ShellChild::process_id for the child variant being spawned — it must return Some for the persistent path on unix.
- Report/fix upstream: spawn should either guarantee a pid for persist_pending or reject the request earlier with a clearer message.
Example fix
// before
let process_group_id = bg_shell
.child
.as_ref()
.and_then(ShellChild::process_id)
.ok_or_else(|| anyhow!("Persistent service has no process group id"))?;
// after
let process_group_id = bg_shell
.child
.as_ref()
.and_then(ShellChild::process_id)
.with_context(|| format!("persistent service '{}' spawned without a pid (child variant: {:?})", task_id, bg_shell.child.as_ref().map(ShellChild::kind)))?; Defensive patterns
Strategy: try-catch
Validate before calling
// Rust: pre-check child variant exposes a pid before persist_pending path
if persist_pending && bg_shell.child.as_ref().and_then(ShellChild::process_id).is_none() {
return Err(anyhow!("cannot persist service: spawned child has no pid on this platform"));
} Type guard
fn child_has_pid(child: Option<&ShellChild>) -> bool {
child.and_then(ShellChild::process_id).is_some()
} Try / catch
match spawn_persistent(...) {
Ok(result) => result,
Err(e) if e.to_string().contains("no process group id") => {
// fall back to a normal background job; persistence unavailable for this child type
spawn_background(...)
}
Err(e) => return Err(e),
} Prevention
- Only request persistent-service semantics for child spawn variants that expose a pid on unix
- Add a unit test spawning the persistent path for every ShellChild variant
- Fail the request at argument-validation time when the platform/wrapper cannot provide a pid
When it happens
Trigger: Calling the shell tool with persist/persistent-service semantics on unix when the freshly spawned child cannot report its pid: the child was spawned without pid capture support, or the child handle variant in use (e.g. a PTY or sandboxed variant) returns None from process_id().
Common situations: Persistent-service spawn on a unix platform where the sandbox/PTY child wrapper does not carry a process id; internal spawn-path changes that leave child = Some(...) but with an id-less variant; code paths where the child was already reaped between spawn and this lookup.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- 125
- 127
- Automation lock must not have hard links
- Codewhale credentials directory must be owned by the…
- Codewhale-owned credential file must be singly linked…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/71bb25fb61e13619.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/tools/shell.rs:2793
terminal_size: tty.then(PtyDimensions::default),
child: Some(child),
#[cfg(windows)]
windows_job,
stdout_thread,
stderr_thread,
work_lifecycle,
lifecycle_seq: 0,
last_lifecycle_status: None,
last_lifecycle_bytes: 0,
};
#[cfg(unix)]
if persist_pending {
let process_group_id = bg_shell
.child
.as_ref()
.and_then(ShellChild::process_id)
.ok_or_else(|| anyhow!("Persistent service has no process group id"))?;
register_pending_persistent_process_group(process_group_id);
}
if let Some(input) = stdin_data
&& let Err(err) = bg_shell.write_stdin(input, false)
{
let _ = bg_shell.kill();
return Err(err);
}
if let Err(err) = bg_shell.publish_lifecycle() {
let _ = bg_shell.kill();
return Err(err);
}
self.processes.insert(task_id.clone(), bg_shell);
spawn_guard.disarm();
// Evict here, not only from `list_jobs()`: retention must not depend onView on GitHub (pinned to 73e0f67d83)