tcpdump icon indicating copy to clipboard operation
tcpdump copied to clipboard

rotate when signal USR2 is received.

Open franky-m opened this issue 9 years ago • 5 comments

With this patch the signal USR2 triggers rotation of the output file.

I see two scenarios where this function might be useful:

  1. 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)

  2. 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

franky-m avatar Dec 01 '16 14:12 franky-m

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.

infrastation avatar Jul 31 '18 09:07 infrastation

As it turns out, SIGUSR2 is in POSIX, Linux, FreeBSD, NetBSD, OpenBSD and illumos, so that particular point is moot.

infrastation avatar Oct 31 '21 21:10 infrastation

(Also in Solaris 9, 10 and 11; AIX 7.1 and 7.2.)

infrastation avatar Oct 31 '21 21:10 infrastation

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.

infrastation avatar Oct 31 '21 21:10 infrastation

Unfortunately, SIGUSR2 was taken for flushing the packet buffer in commit 0e79762 in April 2018.

infrastation avatar Mar 25 '24 10:03 infrastation