From fb5c1fbf6a2639d8fbe7428240429674f7db6bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD=20=D0=A2=D1=80=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Tue, 11 Aug 2026 00:37:41 +0300 Subject: [PATCH] =?UTF-8?q?Ignore=20SIGHUP=20=E2=80=94=20survive=20termina?= =?UTF-8?q?l=20closure=20in=20background?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit __main__.py: add signal.SIGHUP → SIG_IGN before setting up SIGINT/SIGTERM handlers. Sniffer no longer dies when the terminal closes or the shell session ends. README: add Background / Daemon section with nohup examples. --- README.md | 11 +++++++++++ simtrace2_pysniff/__main__.py | 1 + 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 15c08f4..f437635 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,17 @@ Non-TPDU messages (ATR, PPS, card state changes, Fi/Di) print identically in all - **GSMTAP**: ATR (subtype 1) and TPDU (subtype 2) over UDP to Wireshark - **PCAP**: all messages as GSMTAP-encapsulated packets (LINKTYPE 155), openable in Wireshark +## Background / Daemon + +SIGHUP is ignored by default — terminal closure won't kill the sniffer. +To run persistently in the background with output to files: + +```sh +nohup ./sniff-start.sh --output /tmp/sniff.log &> /tmp/sniff-err.log & +# or +FORMAT=timestamp nohup python -m simtrace2_pysniff --output /tmp/sniff.log &> /tmp/sniff-err.log & +``` + ## Library Usage ```python diff --git a/simtrace2_pysniff/__main__.py b/simtrace2_pysniff/__main__.py index 5235774..4b49d82 100644 --- a/simtrace2_pysniff/__main__.py +++ b/simtrace2_pysniff/__main__.py @@ -131,6 +131,7 @@ def main(): file_dumper.close() sys.exit(0) + signal.signal(signal.SIGHUP, signal.SIG_IGN) signal.signal(signal.SIGINT, on_signal) signal.signal(signal.SIGTERM, on_signal)