Update:
[obnox/wireshark/wip.git] / capture_sync.c
index 156e9ed31e0709ac7e6ada17858f817346844819..02223ef28a80d978cffb1d0b3f9e540d3a7529e5 100644 (file)
@@ -97,7 +97,9 @@
 #ifdef _WIN32
 #include "capture-wpcap.h"
 #endif
-#include "ui_util.h"
+
+#include "ui/ui_util.h"
+
 #include <wsutil/file_util.h>
 #include "log.h"
 
@@ -894,14 +896,16 @@ sync_pipe_open_command(const char** argv, int *data_read_fd,
 }
 
 /*
- * Wait for dumpcap to finish.  On success, *msg is unchanged, and 0 is
- * returned.  On failure, *msg points to an error message for the
- * failure, and -1 is returned.  In the latter case, *msg must be
- * freed with g_free().
+ * Close the pipes we're using to read from dumpcap, and wait for it
+ * to exit.  On success, *msgp is unchanged, and the exit status of
+ * dumpcap is returned.  On failure (which includes "dumpcap exited
+ * due to being killed by a signal or an exception"), *msgp points
+ * to an error message for the failure, and -1 is returned.  In the
+ * latter case, *msgp must be freed with g_free().
  */
 static int
 sync_pipe_close_command(int *data_read_fd, int *message_read_fd,
-                        int *fork_child, gchar **msg)
+                        int *fork_child, gchar **msgp)
 {
     ws_close(*data_read_fd);
     if (message_read_fd != NULL)
@@ -912,7 +916,7 @@ sync_pipe_close_command(int *data_read_fd, int *message_read_fd,
     sync_pipe_kill(*fork_child);
 #endif
 
-    return sync_pipe_wait_for_child(*fork_child, msg);
+    return sync_pipe_wait_for_child(*fork_child, msgp);
 }
 
 /*
@@ -1621,7 +1625,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
                That should only be the case for very fast file switches;
                We can't do much more than telling the child to stop.
                (This is the "emergency brake" if the user e.g. wants to
-              switch files every second). */
+              switch files every second).
 
                This can also happen if the user specified "-", meaning
                "standard output", as the capture file. */
@@ -1670,7 +1674,14 @@ sync_pipe_input_cb(gint source, gpointer user_data)
 
 
 
-/* the child process is going down, wait until it's completely terminated */
+/*
+ * dumpcap is exiting; wait for it to exit.  On success, *msgp is
+ * unchanged, and the exit status of dumpcap is returned.  On
+ * failure (which includes "dumpcap exited due to being killed by
+ * a signal or an exception"), *msgp points to an error message
+ * for the failure, and -1 is returned.  In the latter case, *msgp
+ * must be freed with g_free().
+ */
 static int
 sync_pipe_wait_for_child(int fork_child, gchar **msgp)
 {
@@ -1681,7 +1692,6 @@ sync_pipe_wait_for_child(int fork_child, gchar **msgp)
     g_assert(fork_child != -1);
 
     *msgp = NULL; /* assume no error */
-    ret = 0;
 #ifdef _WIN32
     if (_cwait(&fork_child_status, fork_child, _WAIT_CHILD) == -1) {
         *msgp = g_strdup_printf("Error from cwait(): %s", g_strerror(errno));