tcpdump mailing list archives

patch: make tcpdump cleanup on SIGPIPE


From: Jesper Peterson <jesper () endace com>
Date: Mon, 28 Jul 2003 12:48:52 +1200


Tcpdump isn't calling pcap_close when receiving a SIGPIPE. This is currently interacting with support for Endace DAG cards via libpcap. The DAG cards are mostly driven from userspace and like to be closed explicitly via either pcap_close() or exit(), neither of which is called if the signal isn't handled.

The attached patch conditionally applies to non-Win32 only, I presume that is the way to do it. I'm not sure exactly what the Win32 implications are.


--
Jesper Peterson, Senior Software Developer
http://www.endace.com, +64 7 839 0540

Index: tcpdump.c
===================================================================
RCS file: /tcpdump/master/tcpdump/tcpdump.c,v
retrieving revision 1.209
diff -u -r1.209 tcpdump.c
--- tcpdump.c   3 Jun 2003 23:32:42 -0000       1.209
+++ tcpdump.c   28 Jul 2003 00:27:57 -0000
@@ -703,6 +703,9 @@
        }
        init_addrtoname(localnet, netmask);
 
+#ifndef WIN32  
+       (void)setsignal(SIGPIPE, cleanup);
+#endif /* WIN32 */
        (void)setsignal(SIGTERM, cleanup);
        (void)setsignal(SIGINT, cleanup);
        /* Cooperate with nohup(1) */

Current thread: