tcpdump
tcpdump copied to clipboard
rotate when signal USR2 is received.
With this patch the signal USR2 triggers rotation of the output file.
I see two scenarios where this function might be useful:
-
clean shutdown: Do not leave an unrotated partial file when exiting due to CTRL-C or a signal (e.g. # pkill -SIGUSR2 tcpdump; sleep 1; pkill -KILL tcpdump; rm $partial_file)
-
externalize decision on when to rotate: You no longer have to decide when to rotate before tcpdump is started. This way rotation intervall can also be adopted to changing traffic without restarting tcpdump and missing packets.
If 2. is not a missed feature I could also change the patch so that tcpdump simply does a clean shutdown when the signal is sent.
Any feedback is appreciated!
Franky
The proposed change looks OK to me, but needs to be rebased on the current master branch, and needs to disable itself when the OS does not have SIGUSR2. Other reviews are welcome.
As it turns out, SIGUSR2 is in POSIX, Linux, FreeBSD, NetBSD, OpenBSD and illumos, so that particular point is moot.
(Also in Solaris 9, 10 and 11; AIX 7.1 and 7.2.)
Rebased on the current master branch and cleaned up. Not tested. It remains to be established whether this change addresses a sound problem and whether the solution is correct.
Unfortunately, SIGUSR2 was taken for flushing the packet buffer in commit 0e79762 in April 2018.