aboutsummaryrefslogtreecommitdiffstats
path: root/extcap.c
diff options
context:
space:
mode:
authorTomasz Moń <desowin@gmail.com>2022-08-07 16:12:24 +0200
committerTomasz Moń <desowin@gmail.com>2022-08-10 06:18:25 +0200
commitac4e1b86b83d9e322fc19045fbc71b55e418e025 (patch)
treecaba2198038d68018569eb19000bdef95a79c671 /extcap.c
parentc1861ad1cc5ea673ee373e0cb69bfcd638ef06a2 (diff)
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.
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c14
1 files changed, 6 insertions, 8 deletions
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 =