Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0: Fix exit code for "not found" (after GP-994)

Dan13dc22099b6e
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/pty/linux/LinuxPtySessionLeader.java b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/pty/linux/LinuxPtySessionLeader.java
index 1dc9be5e7a..1548d91605 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/pty/linux/LinuxPtySessionLeader.java
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/pty/linux/LinuxPtySessionLeader.java
@@ -79,7 +79,7 @@ public class LinuxPtySessionLeader {
}
}
System.err.println("Could not execute " + subArgs.get(0) + ": " + t.getMessage());
- System.exit(-1);
+ System.exit(127);
}
}
}
diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/test/java/agent/gdb/pty/linux/LinuxPtyTest.java b/Ghidra/Debug/Debugger-agent-gdb/src/test/java/agent/gdb/pty/linux/LinuxPtyTest.java
index f3ac1d9420..16c1d709c6 100644
--- a/Ghidra/Debug/Debugger-agent-gdb/src/test/java/agent/gdb/pty/linux/LinuxPtyTest.java
+++ b/Ghidra/Debug/Debugger-agent-gdb/src/test/java/agent/gdb/pty/linux/LinuxPtyTest.java
@@ -84,10 +84,9 @@ public class LinuxPtyTest extends AbstractPtyTest {
PtySession dies =
pty.getChild().session(new String[] { "thisHadBetterNotExist" }, null);
/**
- * NOTE: Java subprocess dies with code 1 on unhandled exception. TODO: Is there a nice
- * way to distinguish whether the code is from java or the execed image?
+ * Choice of 127 is based on bash setting "exit code" to 127 for "command not found"
*/
- assertEquals(1, dies.waitExited());
+ assertEquals(127, dies.waitExited());
}
}