diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-01-08 09:32:15 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-01-08 09:32:15 +0000 |
commit | 12d566c0acad92a519b0bfef73a955a648f555fe (patch) | |
tree | 2b2117f07519ea791bd6a6fef23dcce9b3ac2270 /capture.c | |
parent | 86a251065d768c8e88a6f5c62dc0e53d93cabb8e (diff) | |
download | wireshark-12d566c0acad92a519b0bfef73a955a648f555fe.tar.gz wireshark-12d566c0acad92a519b0bfef73a955a648f555fe.tar.bz2 wireshark-12d566c0acad92a519b0bfef73a955a648f555fe.zip |
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.
svn path=/trunk/; revision=4498
Diffstat (limited to 'capture.c')
-rw-r--r-- | capture.c | 19 |
1 files changed, 17 insertions, 2 deletions
@@ -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) { |