bee-san/RustScan · error

Unknown exit status

Error message

Unknown exit status

What it means

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.

Source

Thrown at src/scripts/mod.rs:306

        .args([arg, script])
        .stdin(Stdio::piped())
        .stderr(Stdio::piped())
        .output()
    {
        Ok(output) => {
            let status = output.status;

            let es = match status.code() {
                Some(code) => code,
                _ => {
                    #[cfg(unix)]
                    {
                        status.signal().unwrap()
                    }

                    #[cfg(windows)]
                    {
                        return Err(anyhow!("Unknown exit status"));
                    }
                }
            };

            if es != 0 {
                return Err(anyhow!("Exit code = {}", es));
            }
            Ok(String::from_utf8_lossy(&output.stdout).into_owned())
        }
        Err(error) => {
            debug!("Command error {error}",);
            Err(anyhow!(error.to_string()))
        }
    }
}

pub fn find_scripts(path: PathBuf) -> Result<Vec<PathBuf>> {
    if path.is_dir() {

View on GitHub (pinned to e9dadb4a30)

Solutions

  1. Re-run the script manually with the same call_format to see its raw exit behavior on that OS
  2. Check the script/interpreter for Windows compatibility (line endings, shebang lines, paths)
  3. Wrap the script so it always exits with a numeric code (e.g. 'exit %errorlevel%' in batch)
  4. On Unix this branch is nearly unreachable — if seen on Linux, verify the interpreter binary exists and is executable

Example fix

// before: script.bat
my_command
// after
my_command
exit /b %errorlevel%
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check the script can execute and produce a code before handing it to rustscan
fn script_exits_cleanly(call_format: &str) -> bool {
    std::process::Command::new(&resolve_program(call_format))
        .args(["--version"])
        .output()
        .map(|o| o.status.success())
        .unwrap_or(false)
}

Try / catch

match execute_script_result {
    Err(e) if e.to_string().contains("Unknown exit status") => {
        eprintln!("Script crashed without an exit code (likely Windows); rerun with native wrapper");
        // retry once via cmd /c or the interpreter directly
    }
    other => propagate(other),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of bee-san/RustScan@e9dadb4a30 (2026-09-02). Data as JSON: /api/errors/b1737cfd4512a4da. Report an issue: GitHub.