{"record":{"id":"b899dccca3cb645f","repo":"ClementTsang/bottom","slug":"error-code-unknown-err","errorCode":null,"errorMessage":"Error code unknown - {err}","messagePattern":"Error code unknown - (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/process_killer.rs","lineNumber":83,"sourceCode":"    // code not 0).\n    let output = unsafe { libc::kill(pid, signal as i32) };\n\n    if output != 0 {\n        // We had an error...\n        let err_code = std::io::Error::last_os_error().raw_os_error();\n        let err = match err_code {\n            Some(libc::ESRCH) => \"the target process did not exist.\",\n            Some(libc::EPERM) => {\n                \"the calling process does not have the permissions to terminate the target process(es).\"\n            }\n            Some(libc::EINVAL) => \"an invalid signal was specified.\",\n            _ => \"Unknown error occurred.\",\n        };\n\n        if let Some(err_code) = err_code {\n            bail!(format!(\"Error code {err_code} - {err}\"))\n        } else {\n            bail!(format!(\"Error code unknown - {err}\"))\n        };\n    }\n\n    Ok(())\n}\n","sourceCodeStart":65,"sourceCodeEnd":89,"githubUrl":"https://github.com/ClementTsang/bottom/blob/b77d3175028849824e987c35177e8f61450d72e7/src/utils/process_killer.rs#L65-L89","documentation":"Sibling of the `Error code {err_code}` bail in the Unix `kill_process_given_pid`: when `std::io::Error::last_os_error().raw_os_error()` returns `None` — i.e. the OS did not report a recognizable errno — the library bails with `Error code unknown - {err}` (err will read 'Unknown error occurred.'). This is a rare fallback path meaning `libc::kill` failed but the thread-local errno could not be interpreted.","triggerScenarios":"`libc::kill` returned non-zero but `last_os_error()` produced an error without a raw errno (e.g. errno was clobbered by an intervening call, or the error carried no OS code).","commonSituations":"Unusual libc/platform conditions or interleaving code between the failed `kill` and the errno read on exotic libc implementations; very rare in practice on standard Linux/macOS.","solutions":["Retry the kill once and inspect the new error — transient errno clobbering is usually not reproducible","Check that the PID is valid and the signal value is in range, then retry with a corrected call","Capture `std::io::Error::last_os_error()` display text for the real cause and report it upstream if it persists"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match kill_process_given_pid(pid, signal) {\n    Err(e) if e.to_string().contains(\"Error code unknown\") => {\n        // retry once; errno was unreadable\n        if let Err(e2) = kill_process_given_pid(pid, signal) {\n            eprintln!(\"kill retry failed: {e2}\");\n        }\n    }\n    other => { let _ = other; }\n}","preventionTips":["Retry once on unknown-errno failures before giving up","Keep errno-reading code immediately after the failing libc call","Validate pid and signal before calling so only genuine OS failures reach this path","Log the full std::io::Error display for diagnostics when it recurs"],"tags":["unix","signal","libc","process-kill","errno"],"backgroundTag":"internal-invariant-violation","analyzedSha":"b77d3175028849824e987c35177e8f61450d72e7","analyzedAt":"2026-09-07T14:53:21.246Z","contentChangedAt":"2026-09-07T14:53:21.246Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}