{"record":{"id":"7724ac181ffbc786","repo":"uutils/coreutils","slug":"kill-error-unsupported-signal","errorCode":null,"errorMessage":"kill-error-unsupported-signal","messagePattern":"kill-error-unsupported-signal","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"warning","filePath":"src/uu/kill/src/platform/windows.rs","lineNumber":22,"sourceCode":"// file that was distributed with this source code.\n\n// spell-checker:ignore pids\n\n//! Windows implementation of `kill`'s platform facade, built on the signal\n//! emulation in [`uucore::process`]. PID 0 targets the Job object `kill` runs\n//! in, the closest Windows analog of a process group. STOP (no process-suspend\n//! API) and negative pids (no way to name another process's group) are\n//! rejected.\n\nuse std::io;\n\nuse uucore::process::{enable_debug_privilege, send_signal_to_own_group, send_signal_to_pid};\nuse uucore::translate;\n\nconst SIGNAL_STOP: usize = 19;\n\nfn unsupported(message: String) -> io::Error {\n    io::Error::new(io::ErrorKind::Unsupported, message)\n}\n\npub(crate) fn send_signal(pid: i32, sig: usize) -> io::Result<()> {\n    if sig == SIGNAL_STOP {\n        return Err(unsupported(translate!(\"kill-error-unsupported-signal\")));\n    }\n    match u32::try_from(pid) {\n        // Fails exactly for pid < 0.\n        Err(_) => Err(unsupported(translate!(\n            \"kill-error-negative-pid-unsupported\"\n        ))),\n        Ok(pid) => {\n            // Group members need the same rights as a single target.\n            enable_debug_privilege();\n            if pid == 0 {\n                send_signal_to_own_group(sig)\n            } else {\n                send_signal_to_pid(pid, sig)","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/uutils/coreutils/blob/92995feca29e324a7c559ede91db81c32d9f5d59/src/uu/kill/src/platform/windows.rs#L4-L40","documentation":"On Windows, `kill` cannot deliver stop-type signals (SIGNAL_STOP, sig 19); `send_signal` returns `io::ErrorKind::Unsupported` with the localized `kill-error-unsupported-signal` message. The platform simply has no equivalent mechanism implemented.","triggerScenarios":"Calling `kill -19 <pid>` / `kill -STOP` / `kill -TSTP` on Windows, or invoking `send_signal(pid, 19)` via the Windows code path.","commonSituations":"Shell scripts ported from Unix that suspend/resume jobs with STOP/CONT, cross-platform build scripts using `kill -STOP`, or CI jobs that run Unix scripts on Windows runners.","solutions":["Guard the signal choice by platform: skip STOP/TSTP signals on Windows","Use `kill -9` (SIGKILL termination) instead of STOP when suspension is not required","Restrict the script to Unix, or use a Windows-native suspend mechanism (e.g. DebugActiveProcess-based tools)","Handle the error gracefully: check `err.kind() == ErrorKind::Unsupported` and warn instead of failing"],"exampleFix":"// before\nkill -STOP $pid\n// after\nif [ \"$(uname)\" = \"Windows_NT\" ]; then echo \"STOP unsupported on Windows\" >&2; else kill -STOP $pid; fi","handlingStrategy":"validation","validationCode":"# fail early on unsupported signals\n[[ \"$sig\" == 19 || \"$sig\" == STOP || \"$sig\" == TSTP ]] && [ \"$(uname)\" = Windows_NT ] && { echo \"sig unsupported\" >&2; exit 2; }","typeGuard":"fn is_stop_signal(sig: usize) -> bool { sig == 19 } // gate before calling send_signal","tryCatchPattern":"match kill_result {\n    Err(e) if e.kind() == io::ErrorKind::Unsupported => {\n        eprintln!(\"signal {sig} is not supported on this platform\");\n    }\n    r => r?,\n}","preventionTips":["Never hardcode Unix-only signals (STOP/TSTP/CONT) in cross-platform scripts","Check cfg!(windows) before issuing stop signals","Prefer SIGKILL/SIGTERM, which have Windows equivalents, when possible","Centralize signal constants in one platform-aware module"],"tags":["windows","signals","kill","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"92995feca29e324a7c559ede91db81c32d9f5d59","analyzedAt":"2026-09-20T12:39:35.476Z","contentChangedAt":"2026-09-20T12:39:35.476Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}