affaan-m/ECC · error · anyhow::Error
taskkill exited with status {status}
Error message
taskkill exited with status {status} What it means
On Windows, the kill_process function invokes taskkill /PID <pid> /T /F to terminate a process tree. If taskkill exits with a non-zero status code, the function returns an error. This typically means the target process does not exist, access is denied, or taskkill itself failed.
Source
Thrown at ecc2/src/session/manager.rs:3618
#[cfg(unix)]
fn kill_process(pid: u32) -> Result<()> {
send_signal(pid, libc::SIGTERM)?;
std::thread::sleep(std::time::Duration::from_millis(1200));
send_signal(pid, libc::SIGKILL)?;
Ok(())
}
#[cfg(windows)]
fn kill_process(pid: u32) -> Result<()> {
let status = std::process::Command::new("taskkill")
.args(["/PID", &pid.to_string(), "/T", "/F"])
.status()
.with_context(|| format!("Failed to invoke taskkill for process {pid}"))?;
if status.success() {
Ok(())
} else {
Err(anyhow::anyhow!("taskkill exited with status {status}"))
}
}
#[cfg(unix)]
fn send_signal(pid: u32, signal: i32) -> Result<()> {
let outcome = unsafe { libc::kill(pid as i32, signal) };
if outcome == 0 {
return Ok(());
}
let error = std::io::Error::last_os_error();
if error.raw_os_error() == Some(libc::ESRCH) {
return Ok(());
}
Err(error).with_context(|| format!("Failed to kill process {pid}"))
}
View on GitHub (pinned to 01e15490f0)
Solutions
- Check if the process is still running before attempting to kill it (track exit independently)
- Run the ECC process with sufficient privileges to terminate the target process
- Treat ESRCH-equivalent (process already gone) as success rather than error
- Use the /F flag (already present) and ensure /T is used to kill the entire process tree
Example fix
// before
kill_process(pid)?;
// after
match kill_process(pid) {
Ok(()) => {},
Err(e) if e.to_string().contains("taskkill exited") => {
tracing::warn!("process {pid} may have already exited: {e}");
}
Err(e) => return Err(e),
} Defensive patterns
Strategy: try-catch
Try / catch
match kill_process(pid) {
Ok(()) => Ok(()),
Err(e) if e.to_string().contains("taskkill exited") => {
tracing::warn!("taskkill failed for pid {pid}, process may have already exited: {e}");
Ok(())
}
Err(e) => Err(e),
} Prevention
- Check if the process is still alive before attempting to kill it on Windows
- Run ECC with sufficient privileges to terminate spawned processes
- Treat 'process already gone' as success to avoid cascading errors in cleanup paths
When it happens
Trigger: Calling kill_process(pid) on Windows where taskkill returns a non-zero exit code — the process may have already exited, the PID may be invalid, or the user lacks permissions.
Common situations: Process already exited before the kill call. PID belongs to a process owned by a different user or with higher privileges. taskkill.exe is not available or restricted by group policy. Antivirus blocking taskkill.
Related errors
- Command "${commandName}" terminated by signal ${result.signa
- File path contains unsafe shell characters
- Formatter exited with status ${result.status}
- Claude Code command contains characters that are unsafe for
- ${command} ${args.join(' ')} failed: ${result.error.message}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/907d7abe3330aeea.
Report an issue: GitHub.