mandiant / Ghidrathon

The FLARE team's open-source extension to add Python 3 scripting to Ghidra.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sys.exit() closes Ghidra instead of terminating the script

SourceDiver42 opened this issue · comments

Hello,
In the default Python interpreter of Ghidra, invoking sys.exit() or just exit() stops the script execution. This is handy if you want to prevent your script from proceeding with the execution. When I ported my script to Ghidrathon, it took me some time to figure out why Ghidra was crashing when executing the script: sys.exit() exits Ghidra, which is not the expected behavior (terminating the script). The only way of stopping scripts prematurely is to raise an error, as returning from a non-function is not allowed.

TLDR: sys.exit() should quit the current script/Python environment instead of closing Ghidra

@SourceDiver42 thank you for reporting this. I agree that Ghidra should not terminate as a result of calling sys.exit from Ghidrathon. We will take a look at our options for changing this behavior.