{"record":{"id":"1fa4d4d0e54ce69c","repo":"imsnif/bandwhich","slug":"failed-to-execute-process","errorCode":null,"errorMessage":"failed to execute process","messagePattern":"failed to execute process","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/os/lsof_utils.rs","lineNumber":155,"sourceCode":"\n        Some(LocalSocket { ip, port, protocol })\n    }\n}\n\npub fn get_connections() -> RawConnections {\n    let content = run([\"-n\", \"-P\", \"-i4\", \"-i6\", \"+c\", \"0\"]);\n    RawConnections::new(content)\n}\n\nfn run<I, S>(args: I) -> String\nwhere\n    I: IntoIterator<Item = S>,\n    S: AsRef<OsStr>,\n{\n    let output = Command::new(\"lsof\")\n        .args(args)\n        .output()\n        .expect(\"failed to execute process\");\n\n    String::from_utf8_lossy(&output.stdout).into_owned()\n}\n\npub struct RawConnections {\n    content: Vec<RawConnection>,\n}\n\nimpl RawConnections {\n    pub fn new(content: String) -> RawConnections {\n        let lines: Vec<RawConnection> = content.lines().flat_map(RawConnection::new).collect();\n\n        RawConnections { content: lines }\n    }\n}\n\nimpl Iterator for RawConnections {\n    type Item = RawConnection;","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/imsnif/bandwhich/blob/1899870cea8bb377948f05cfea64733ec6ea2cd6/src/os/lsof_utils.rs#L137-L173","documentation":"bandwhich shells out to the system `lsof` utility to map sockets to processes. In `run`, if `Command::new(\"lsof\").args(args).output()` fails (most commonly lsof is not installed/not on PATH), it panics with 'failed to execute process'.","triggerScenarios":"`run()` called by `get_connections()` when `lsof` is missing from PATH, lacks execute permission, or spawn fails due to resource limits (fork failures).","commonSituations":"Linux systems without the lsof package installed (minimal Docker images, slim distros), PATH missing /usr/sbin or custom bin dirs, or corrupted/blocked binaries.","solutions":["Install lsof: Debian/Ubuntu `sudo apt install lsof`, RHEL/Fedora `sudo dnf install lsof`, Arch `sudo pacman -S lsof`","Verify `which lsof` finds it and PATH includes its directory","If the binary exists, check execute permissions (`chmod +x $(which lsof)`)","In minimal containers, add lsof to the image, or run on a platform where bandwhich uses an alternative backend"],"exampleFix":"// before\nsudo bandwhich  # panicked at 'failed to execute process' (no lsof)\n// after\nsudo apt install lsof && sudo bandwhich","handlingStrategy":"fallback","validationCode":"// shell: verify lsof exists before launching\ncommand -v lsof >/dev/null 2>&1 || { echo \"lsof is required: install it first\"; exit 1; }","typeGuard":null,"tryCatchPattern":"match Command::new(\"lsof\").args(args).output() {\n    Ok(output) => String::from_utf8_lossy(&output.stdout).into_owned(),\n    Err(e) => { eprintln!(\"lsof spawn failed: {e}; install lsof\"); String::new() }\n}","preventionTips":["Install lsof on all hosts/containers that run bandwhich (it is a runtime dependency on Linux)","Keep /usr/bin or /usr/sbin in PATH so lsof is discoverable","In Docker images, add lsof to the base image packages","Periodically verify `which lsof` after image slimming or distro upgrades"],"tags":["rust","lsof","process","dependencies"],"backgroundTag":"missing-dependency","analyzedSha":"1899870cea8bb377948f05cfea64733ec6ea2cd6","analyzedAt":"2026-09-08T10:26:38.858Z","contentChangedAt":"2026-09-08T10:26:38.858Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}