{"record":{"id":"b1737cfd4512a4da","repo":"bee-san/RustScan","slug":"unknown-exit-status","errorCode":null,"errorMessage":"Unknown exit status","messagePattern":"Unknown exit status","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/scripts/mod.rs","lineNumber":306,"sourceCode":"        .args([arg, script])\n        .stdin(Stdio::piped())\n        .stderr(Stdio::piped())\n        .output()\n    {\n        Ok(output) => {\n            let status = output.status;\n\n            let es = match status.code() {\n                Some(code) => code,\n                _ => {\n                    #[cfg(unix)]\n                    {\n                        status.signal().unwrap()\n                    }\n\n                    #[cfg(windows)]\n                    {\n                        return Err(anyhow!(\"Unknown exit status\"));\n                    }\n                }\n            };\n\n            if es != 0 {\n                return Err(anyhow!(\"Exit code = {}\", es));\n            }\n            Ok(String::from_utf8_lossy(&output.stdout).into_owned())\n        }\n        Err(error) => {\n            debug!(\"Command error {error}\",);\n            Err(anyhow!(error.to_string()))\n        }\n    }\n}\n\npub fn find_scripts(path: PathBuf) -> Result<Vec<PathBuf>> {\n    if path.is_dir() {","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/bee-san/RustScan/blob/e9dadb4a30dd0f3cc8b9b1c630a28ad351f8dbc3/src/scripts/mod.rs#L288-L324","documentation":"execute_script checks the exit status of the spawned script process. If the process neither exited normally nor with a signal (only possible on non-Unix platforms), the status is inexplicable and the function returns 'Unknown exit status'. On Windows, every non-zero, non-code exit reaches this branch because signal() is not applicable.","triggerScenarios":"Running a script on Windows that terminates without a normal exit code (e.g. killed forcibly, access violation reported through STATUS_* codes without a code branch); any platform where ExitStatus::code() and signal() both fail.","commonSituations":"Windows scripts crashing hard (e.g. cmd killed by taskkill /F, DLL load failures); custom interpreter executables terminating abnormally; cross-platform CI where Windows behaves differently than Linux.","solutions":["Re-run the script manually with the same call_format to see its raw exit behavior on that OS","Check the script/interpreter for Windows compatibility (line endings, shebang lines, paths)","Wrap the script so it always exits with a numeric code (e.g. 'exit %errorlevel%' in batch)","On Unix this branch is nearly unreachable — if seen on Linux, verify the interpreter binary exists and is executable"],"exampleFix":"// before: script.bat\nmy_command\n// after\nmy_command\nexit /b %errorlevel%","handlingStrategy":"retry","validationCode":"// Pre-check the script can execute and produce a code before handing it to rustscan\nfn script_exits_cleanly(call_format: &str) -> bool {\n    std::process::Command::new(&resolve_program(call_format))\n        .args([\"--version\"])\n        .output()\n        .map(|o| o.status.success())\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match execute_script_result {\n    Err(e) if e.to_string().contains(\"Unknown exit status\") => {\n        eprintln!(\"Script crashed without an exit code (likely Windows); rerun with native wrapper\");\n        // retry once via cmd /c or the interpreter directly\n    }\n    other => propagate(other),\n}","preventionTips":["Test scripts on Windows separately; force a numeric exit code (exit /b %errorlevel%)","Avoid force-killing script processes (taskkill /F) which lose the exit code","Keep interpreters and scripts Windows-compatible (CRLF, no shebang reliance)","On Unix, ensure the interpreter binary exists and is executable"],"tags":["rust","scripts","windows","process-exit"],"backgroundTag":"unknown-process-exit-status","analyzedSha":"e9dadb4a30dd0f3cc8b9b1c630a28ad351f8dbc3","analyzedAt":"2026-09-02T04:27:33.555Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}