SIGHUP: ignore only when in background (stdin not a tty)

Use sys.stdin.isatty() to auto-detect: foreground sessions still
respond to SIGHUP (terminal close kills the process as expected),
background/piped processes ignore it and survive.
This commit is contained in:
catarrh committed 2026-08-11 01:02:07 +03:00
1 parent fb5c1fbf6a
commit f8e9cb1018
2 files changed
+6 -2

No files matched your search

+2 -1
View File
@@ -131,7 +131,8 @@ def main():
file_dumper.close()
sys.exit(0)
signal.signal(signal.SIGHUP, signal.SIG_IGN)
if not sys.stdin.isatty():
signal.signal(signal.SIGHUP, signal.SIG_IGN)
signal.signal(signal.SIGINT, on_signal)
signal.signal(signal.SIGTERM, on_signal)