aboutsummaryrefslogtreecommitdiffstats
path: root/capture.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-01-08 09:32:15 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-01-08 09:32:15 +0000
commitdc39e6952e0f1c60a35d598b58f8e2497042e4db (patch)
tree2b2117f07519ea791bd6a6fef23dcce9b3ac2270 /capture.c
parente6a156eeda7a54efd09b4b79a60b1259cffd50cd (diff)
Add a routine to kill a capture child if it exists, so that if we exit
(by deleting the main window or selecting File->Quit or typing ^Q) while an "Update list of packets in real time" capture is in progress, we can abort the capture. Arrange that "fork_child" is -1 when there is no capture child, so said routine knows when it can kill the child. When we exit, kill off any capture child, using that routine, and, if we're exiting due to a request to delete the main window and, if a read is in progress (from an "Update list of packets in real time" capture), don't delete the main window - just set the "Read aborted" flag, so that the code doing the read will see that flag (it will be called because the pipe to the capture child is closed due to the child exiting) will see that and clean up and exit itself. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@4498 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'capture.c')
-rw-r--r--capture.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/capture.c b/capture.c
index b28f330996..46c626b924 100644
--- a/capture.c
+++ b/capture.c
@@ -1,7 +1,7 @@
/* capture.c
* Routines for packet capture windows
*
- * $Id: capture.c,v 1.165 2002/01/04 06:27:42 guy Exp $
+ * $Id: capture.c,v 1.166 2002/01/08 09:32:14 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -173,7 +173,7 @@ static int sync_pipe[2]; /* used to sync father */
enum PIPES { READ, WRITE }; /* Constants 0 and 1 for READ and WRITE */
int quit_after_cap; /* Makes a "capture only mode". Implies -k */
gboolean capture_child; /* if this is the child for "-S" */
-static int fork_child; /* In parent, process ID of child */
+static int fork_child = -1; /* If not -1, in parent, process ID of child */
static guint cap_input_id;
/*
@@ -893,6 +893,9 @@ wait_for_child(gboolean always_report)
"Child capture process died: wait status %#o", wstatus);
}
}
+
+ /* No more child process. */
+ fork_child = -1;
#endif
}
@@ -1963,6 +1966,18 @@ capture_stop(void)
#endif
}
+void
+kill_capture_child(void)
+{
+ /*
+ * XXX - find some way of signaling the child in Win32.
+ */
+#ifndef _WIN32
+ if (fork_child != -1)
+ kill(fork_child, SIGTERM); /* SIGTERM so it can clean up if necessary */
+#endif
+}
+
static void
capture_pcap_cb(u_char *user, const struct pcap_pkthdr *phdr,
const u_char *pd) {