From ac4e1b86b83d9e322fc19045fbc71b55e418e025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Sun, 7 Aug 2022 16:12:24 +0200 Subject: wsutil: Use GIOChannel for standard pipes Remove ws_read_string_from_pipe() as this function encourages bad design and is no longer necessary. Extcap stderr is read only after the child process has finished and thus the read will never block. Close process information thread handle right away as we don't use it. Remove unused ws_pipe_t member variables. --- extcap.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'extcap.c') diff --git a/extcap.c b/extcap.c index f7b8c1c10f..e09c5b3c68 100644 --- a/extcap.c +++ b/extcap.c @@ -1323,22 +1323,19 @@ static void extcap_child_watch_cb(GPid pid, gint status _U_, gpointer user_data) pipedata = (ws_pipe_t *)interface_opts->extcap_pipedata; if (pipedata != NULL) { - if (pipedata->stdout_fd > 0) - { - ws_close(pipedata->stdout_fd); - } + g_io_channel_unref(pipedata->stdout_io); - if (pipedata->stderr_fd > 0) + if (pipedata->stderr_io) { #define STDERR_BUFFER_SIZE 1024 gchar *buffer = (gchar *)g_malloc0(STDERR_BUFFER_SIZE + 1); - ws_read_string_from_pipe(ws_get_pipe_handle(pipedata->stderr_fd), buffer, STDERR_BUFFER_SIZE + 1); + g_io_channel_read_chars(pipedata->stderr_io, buffer, STDERR_BUFFER_SIZE, NULL, NULL); if (strlen(buffer) > 0) { interface_opts->extcap_stderr = g_strdup(buffer); } g_free(buffer); - ws_close(pipedata->stderr_fd); + g_io_channel_unref(pipedata->stderr_io); } g_free(pipedata); @@ -1614,7 +1611,8 @@ extcap_init_interfaces(capture_session *cap_session) continue; } - ws_close(pipedata->stdin_fd); + g_io_channel_unref(pipedata->stdin_io); + pipedata->stdin_io = NULL; interface_opts->extcap_pid = pid; interface_opts->extcap_child_watch = -- cgit v1.2.3