{"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":"io::Error","httpStatus":null,"severity":"error","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/325183372aaf86d8ae6feaf4f9548f74fe815102/src/uu/kill/src/platform/windows.rs#L4-L40","documentation":"On Windows, kill can only deliver a limited set of signals via native APIs. Requesting a signal the platform cannot send — notably SIGNAL_STOP (suspend), or any unimplemented signal number — returns io::ErrorKind::Unsupported with this translated message. It is a platform-capability limitation, not a bad PID or permission issue.","triggerScenarios":"Calling kill's send_signal(pid, sig) on Windows with sig == 19 (SIGNAL_STOP) or another signal Windows does not support (e.g., simulating SIGTSTP/SIGSTOP semantics).","commonSituations":"Scripts written for Unix that `kill -STOP`/`kill -TSTP` a process, job-control emulation in shells on Windows, cross-platform tooling that suspends/resumes worker processes.","solutions":["Avoid STOP-type signals on Windows; terminate with a supported signal or use process suspension APIs explicitly","Guard the call at runtime: check target OS (cfg!(windows)) and skip/replace suspend logic there","On Windows use taskkill /PID <pid> for termination or a Windows-specific suspend mechanism (NtSuspendProcess) via a crate","Refactor job control to be POSIX-only, gating it behind a unix-only code path"],"exampleFix":"// before\nkill::send_signal(pid, 19)?; // SIGNAL_STOP\n// after\nif cfg!(windows) {\n    eprintln!(\"suspend not supported on windows\");\n} else {\n    kill::send_signal(pid, 19)?;\n}","handlingStrategy":"fallback","validationCode":"// check signal support on the current platform before sending\nconst SIGNAL_STOP: usize = 19;\nif cfg!(windows) && (sig == SIGNAL_STOP) {\n    eprintln!(\"{sig} unsupported on windows\");\n    return;\n}","typeGuard":"fn signal_supported(sig: usize) -> bool {\n    !(cfg!(windows) && sig == 19) // SIGNAL_STOP\n}","tryCatchPattern":"match kill::send_signal(pid, sig) {\n    Err(e) if e.kind() == std::io::ErrorKind::Unsupported => {\n        eprintln!(\"signal {sig} unsupported here; using termination instead\");\n        kill::send_signal(pid, default_terminate_signal)?;\n    }\n    other => other?,\n}","preventionTips":["Gate job-control (STOP/TSTP) logic behind cfg(unix)","Map signals to Windows equivalents (terminate) with explicit fallbacks","Test cross-platform scripts for signal usage before deployment"],"tags":["kill","windows","signal","unsupported"],"backgroundTag":"unsupported-signal","analyzedSha":"325183372aaf86d8ae6feaf4f9548f74fe815102","analyzedAt":"2026-08-31T11:11:36.175Z","contentChangedAt":"2026-08-31T11:11:36.175Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}