diff options
author | Gerald Combs <gerald@wireshark.org> | 2018-03-02 09:11:31 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2018-03-02 18:07:58 +0000 |
commit | 80d652f06e205be070ba151158042c12adbb2d7e (patch) | |
tree | 937a17493e2c326a0716324d0770242d56dce4b0 /wsutil/ws_pipe.c | |
parent | 184ef021110d52d123104c77863df92f7ecc5f6e (diff) |
More spawned process handling updates.
Document ws_pipe.h. Define invalid PIDs in one place.
Extcap didn't use stdin before 1a0987904f. Make sure we close it.
Change-Id: I7a69cd9b5137ae82435e64628a22e4d812d58f89
Reviewed-on: https://code.wireshark.org/review/26226
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'wsutil/ws_pipe.c')
-rw-r--r-- | wsutil/ws_pipe.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/wsutil/ws_pipe.c b/wsutil/ws_pipe.c index 3649276864..7628a779eb 100644 --- a/wsutil/ws_pipe.c +++ b/wsutil/ws_pipe.c @@ -170,9 +170,16 @@ gboolean ws_pipe_spawn_sync(gchar *dirname, gchar *command, gint argc, gchar **a return result; } +void ws_pipe_init(ws_pipe_t *ws_pipe) +{ + if (!ws_pipe) return; + memset(ws_pipe, 0, sizeof(ws_pipe_t)); + ws_pipe->pid = WS_INVALID_PID; +} + GPid ws_pipe_spawn_async(ws_pipe_t *ws_pipe, GPtrArray *args) { - GPid pid = INVALID_EXTCAP_PID; + GPid pid = WS_INVALID_PID; #ifdef _WIN32 gint cnt = 0; @@ -256,9 +263,14 @@ GPid ws_pipe_spawn_async(ws_pipe_t *ws_pipe, GPtrArray *args) g_setenv("PATH", oldpath, TRUE); #else - g_spawn_async_with_pipes(NULL, (gchar **)args->pdata, NULL, + GError *error = NULL; + gboolean spawned = g_spawn_async_with_pipes(NULL, (gchar **)args->pdata, NULL, (GSpawnFlags) G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, - &pid, &ws_pipe->stdin_fd, &ws_pipe->stdout_fd, &ws_pipe->stderr_fd, NULL); + &pid, &ws_pipe->stdin_fd, &ws_pipe->stdout_fd, &ws_pipe->stderr_fd, &error); + if (!spawned) { + g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Error creating async pipe: %s", error->message); + g_free(error->message); + } #endif ws_pipe->pid = pid; |