forked from osmocom/wireshark
some clarification of the capture child thing
svn path=/trunk/; revision=13535
This commit is contained in:
parent
93c46dde91
commit
e7fafa28c6
25
capture.c
25
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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
23
gtk/main.c
23
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue