aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2005-02-27 17:30:33 +0000
committerUlf Lamping <ulf.lamping@web.de>2005-02-27 17:30:33 +0000
commite7fafa28c6f94006eee4c8ba91b331fdff724618 (patch)
tree3099df8c4ef0eabd179f11b1d2860d94ee630be2
parent93c46dde912e0f393989fd2a3e50dc0349be9631 (diff)
some clarification of the capture child thing
svn path=/trunk/; revision=13535
-rw-r--r--capture.c25
-rw-r--r--capture.h2
-rw-r--r--gtk/main.c23
3 files changed, 31 insertions, 19 deletions
diff --git a/capture.c b/capture.c
index f728cc2d02..b8d6ad6b62 100644
--- a/capture.c
+++ b/capture.c
@@ -176,7 +176,7 @@ normal_do_capture(capture_options *capture_opts, gboolean is_tempfile)
int err;
/* Not sync mode. */
- capture_succeeded = capture_start(capture_opts, &stats_known, &stats);
+ capture_succeeded = capture_loop_start(capture_opts, &stats_known, &stats);
if (capture_opts->quit_after_cap) {
/* DON'T unlink the save file. Presumably someone wants it. */
main_window_exit();
@@ -285,34 +285,49 @@ stop_capture_signal_handler(int signo _U_)
int
-capture_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats)
+capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats)
{
+ gchar *err_msg;
+
+ g_assert(capture_opts->capture_child);
+
#ifndef _WIN32
/*
* Catch SIGUSR1, so that we exit cleanly if the parent process
* kills us with it due to the user selecting "Capture->Stop".
*/
- if (capture_opts->capture_child)
signal(SIGUSR1, stop_capture_signal_handler);
#endif
+ /* parent must have send us a file descriptor for the opened output file */
+ if (capture_opts->save_file_fd == -1) {
+ /* send this to the standard output as something our parent
+ should put in an error message box */
+ err_msg = g_strdup_printf("%s: \"-W\" flag not specified (internal error)\n", CHILD_NAME);
+ sync_pipe_errmsg_to_parent(err_msg);
+ g_free(err_msg);
+ return FALSE;
+ }
+
return capture_loop_start(capture_opts, stats_known, stats);
}
void
capture_stop(capture_options *capture_opts)
{
-
+ /* stop the capture child, if we have one */
if (capture_opts->sync_mode) {
sync_pipe_stop(capture_opts);
}
-
+
+ /* stop the capture loop */
capture_loop_stop();
}
void
capture_kill_child(capture_options *capture_opts)
{
+ /* kill the capture child, if we have one */
if (capture_opts->sync_mode) {
sync_pipe_kill(capture_opts);
}
diff --git a/capture.h b/capture.h
index a1e135944e..6e880e9985 100644
--- a/capture.h
+++ b/capture.h
@@ -106,7 +106,7 @@ extern gboolean do_capture(capture_options *capture_opts);
/** Do the low-level work of a capture (start the capture child).
* Returns TRUE if it succeeds, FALSE otherwise. */
-extern int capture_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
+extern int capture_child_start(capture_options *capture_opts, gboolean *stats_known, struct pcap_stat *stats);
/** Stop a capture (usually from a menu item). */
extern void capture_stop(capture_options *capture_opts);
diff --git a/gtk/main.c b/gtk/main.c
index 2d7f6cb372..7b09832b84 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -2147,15 +2147,6 @@ main(int argc, char *argv[])
}
}
- if (capture_opts->capture_child) {
- if (capture_opts->save_file_fd == -1) {
- /* XXX - send this to the standard output as something our parent
- should put in an error message box? */
- fprintf(stderr, "%s: \"-W\" flag not specified\n", CHILD_NAME);
- exit(1);
- }
- }
-
if (list_link_layer_types) {
/* Get the list of link-layer types for the capture device. */
lt_list = get_pcap_linktype_list(capture_opts->iface, err_str);
@@ -2269,11 +2260,17 @@ main(int argc, char *argv[])
/* Pop up any queued-up alert boxes. */
display_queued_messages();
- /* XXX - hand these stats to the parent process */
- capture_start(capture_opts, &stats_known, &stats);
+ /* Now start the capture.
+ After the capture is done; there's nothing more for us to do. */
- /* The capture is done; there's nothing more for us to do. */
- gtk_exit(0);
+ /* XXX - hand these stats to the parent process */
+ if(capture_child_start(capture_opts, &stats_known, &stats) == TRUE) {
+ /* capture ok */
+ gtk_exit(0);
+ } else {
+ /* capture failed */
+ gtk_exit(1);
+ }
}
#endif