aboutsummaryrefslogtreecommitdiffstats
path: root/extcap_spawn.c
diff options
context:
space:
mode:
authorRoland Knall <roland.knall@br-automation.com>2016-01-04 18:32:39 +0100
committerAnders Broman <a.broman58@gmail.com>2016-07-30 21:15:39 +0000
commitc611eded2272ac79997fb3ce11f2339dc32b53cb (patch)
tree48d73f9ed21c55448ae77fae24020cf4763da2c7 /extcap_spawn.c
parentc2ac9c5c0316a27f54830fae0b70cf7825c6d99c (diff)
extcap: Use stderr to print error message
This patch reads out the stderr messages from an extcap utility and displays it to an user. It was tested on Qt but not on GTK, but should work their as well. On Mac OS/X and Windows the child_watch does not behave as it was intended. Therefore in extcap_cleanup, the callbacks are called manually, if and only if, they have not been called already. The reason why it displays two error messages is, that by the time the first one is being displayed, glib has not returned from the spawned process on Linux yet. So there is no way to add the stderr correctly, and putting a handler to stderr into interface_opts will lead to memory errors, cause then the code tries to access memory outside of its protection. Bug: 11892 Change-Id: I2db60dd480fed3e01428b91a705057e4f088bd15 Reviewed-on: https://code.wireshark.org/review/12954 Reviewed-by: Roland Knall <rknall@gmail.com> Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'extcap_spawn.c')
-rw-r--r--extcap_spawn.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/extcap_spawn.c b/extcap_spawn.c
index 555958c..4842693 100644
--- a/extcap_spawn.c
+++ b/extcap_spawn.c
@@ -197,7 +197,7 @@ gboolean extcap_spawn_sync ( gchar * dirname, gchar * command, gint argc, gchar
return result;
}
-GPid extcap_spawn_async(interface_options * interface, GPtrArray * args)
+GPid extcap_spawn_async(extcap_userdata * userdata, GPtrArray * args)
{
GPid pid = INVALID_EXTCAP_PID;
@@ -221,12 +221,6 @@ GPid extcap_spawn_async(interface_options * interface, GPtrArray * args)
const gchar * oldpath = g_getenv("PATH");
gchar * newpath = NULL;
-#endif
-
- extcap_userdata * userdata = NULL;
- userdata = (extcap_userdata *) g_malloc0(sizeof(extcap_userdata));
-
-#ifdef _WIN32
newpath = g_strdup_printf("%s;%s", g_strescape(get_progfile_dir(), NULL), oldpath);
g_setenv("PATH", newpath, TRUE);
@@ -279,12 +273,12 @@ GPid extcap_spawn_async(interface_options * interface, GPtrArray * args)
g_setenv("PATH", oldpath, TRUE);
#else
- g_spawn_async(NULL, (gchar **)args->pdata, NULL, (GSpawnFlags) G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL,
- &pid, NULL);
+ g_spawn_async_with_pipes(NULL, (gchar **)args->pdata, NULL,
+ (GSpawnFlags) G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL,
+ &pid, NULL, &userdata->extcap_stdout_rd, &userdata->extcap_stderr_rd, NULL);
#endif
userdata->pid = pid;
- interface->extcap_userdata = userdata;
return pid;
}