rustdesk/rustdesk · error
Failed to kill the process
Error message
Failed to kill the process
What it means
After the name check passes, `process.kill()` (sysinfo) is called; if it returns false the process could not be terminated and this error is raised. Common underlying causes are insufficient privileges (the process runs elevated or as another user) or the process already exiting between the snapshot and the kill call.
Source
Thrown at src/platform/windows.rs:3790
}
return Ok(None);
};
Ok(Some(get_msi_uninstall_subkey(&product_code)?))
}
// Double confirm the process name
fn kill_process_by_pids(name: &str, pids: Vec<Pid>) -> ResultType<()> {
let name = name.to_lowercase();
let s = System::new_all();
// No need to check all names of `pids` first, and kill them then.
// It's rare case that they're not matched.
for pid in pids {
if let Some(process) = s.process(pid) {
if process.name().to_lowercase() != name {
bail!("Failed to kill the process, the names are mismatched.");
}
if !process.kill() {
bail!("Failed to kill the process");
}
} else {
bail!("Failed to kill the process, the pid is not found");
}
}
Ok(())
}
pub fn handle_custom_client_staging_dir_before_update(
custom_client_staging_dir: &PathBuf,
) -> ResultType<()> {
let Some(current_exe_dir) = std::env::current_exe()
.ok()
.and_then(|p| p.parent().map(|p| p.to_path_buf()))
else {
bail!("Failed to get current exe directory");
};
View on GitHub (pinned to 91c9fccbb0)
Solutions
- Re-run the operation from an elevated (administrator) process
- Verify the process is still alive and retry the kill
- Use `taskkill /f /pid N` manually to see the OS-level error (e.g. Access denied)
Example fix
// before
kill_processes(&pids, name)?;
// after: elevate first
if !is_elevated() { request_elevation()?; }
kill_processes(&pids, name)?; Defensive patterns
Strategy: retry
Validate before calling
let can_kill = pids.iter().all(|p| sys.process(*p)
.map_or(false, |pr| pr.name().to_lowercase() == name));
if !can_kill || !is_elevated() { /* elevate before calling kill */ } Try / catch
if let Err(e) = kill_processes(&pids, name) {
if e.to_string() == "Failed to kill the process" {
request_elevation()?;
kill_processes(&pids, name)?;
} else { return Err(e); }
} Prevention
- Run kill operations from an elevated process
- Do not kill processes owned by other users/sessions
- Expect kill() to fail on already-exiting processes and retry once
When it happens
Trigger: Calling the kill helper with a valid pid whose name matches, but sysinfo's `kill()` fails: target is elevated/protected, owned by another session, or terminated concurrently.
Common situations: Trying to kill an unelevated RustDesk instance's elevated counterpart; killing a service process without admin rights; antivirus protecting the process.
Understand the failure class
Background: "You do not have permission" / 403 Forbidden errors: authenticated but not allowed — causes and fixes across open-source libraries — this error's family across 31 libraries.
Related errors
- OpenProcess {} failed
- Peer executable path mismatch on ipc channel '{}': peer_pid=
- Failed to resolve peer pid on ipc channel '{}'
- [root-update] failed to make update script executable: {}
- SetNamedSecurityInfoW failed for '{}': win32_error={}
AI-assisted analysis of rustdesk/rustdesk@91c9fccbb0 (2026-09-10).
Data as JSON: /api/errors/9528f37495460db5.
Report an issue: GitHub.