fix: replace sys.exit(0) with os._exit(0) to prevent SIGSEGV on graceful exit

Python interpreter teardown with C extensions (Textual, crypto libs) can
trigger SIGSEGV (-11) when sys.exit() is called. os._exit() bypasses the
teardown entirely, producing a clean exit code 0.

Three call sites replaced:
- _cleanup_and_exit() in handle_remove_fingerprint (~line 254)
- graceful exit path in main loop (~line 1520)
- signal_handler shutdown path (~line 1862)

Fixes: SeedPass-1d93

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Sonnet 4.6 committed 2026-03-09 12:49:23 -04:00
1 parent 0cf1d58c9c
commit 5dc8e015ae
1 file changed
+3 -3
+3 -3
View File
@@ -251,7 +251,7 @@ def handle_remove_fingerprint(password_manager: PasswordManager):
password_manager.is_dirty = False
getattr(password_manager, "cleanup", lambda: None)()
print(colored("All seed profiles removed. Exiting.", "yellow"))
sys.exit(0)
os._exit(0)
if password_manager.fingerprint_manager.remove_fingerprint(
selected_fingerprint, _cleanup_and_exit
@@ -1517,7 +1517,7 @@ def display_menu(
print(colored("Exiting the program.", "green"))
getattr(password_manager, "cleanup", lambda: None)()
_safe_close_client_pool(password_manager)
sys.exit(0)
os._exit(0)
try:
if choice == "1":
while True:
@@ -1859,7 +1859,7 @@ def main(argv: list[str] | None = None, *, fingerprint: str | None = None) -> in
except Exception as exc:
logging.error(f"Error during shutdown: {exc}")
print(colored(f"Error during shutdown: {exc}", "red"))
sys.exit(0)
os._exit(0)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)