diff options
author | Ralf Engels <ralf.engels@nokia.com> | 2010-06-28 14:26:30 +0200 |
---|---|---|
committer | Ralf Engels <ralf.engels@nokia.com> | 2010-06-28 14:26:30 +0200 |
commit | 33690118e24b9c5dd5bb5472306855f4bf022270 (patch) | |
tree | 3e5b2f7fe93444fa2982019bdf4d5f54bb13ade6 | |
parent | dd254f0c60bfa8ba185a58335659b752a0fd6aa9 (diff) |
Reap child processes to prevent zombies
-rw-r--r-- | qtpluginloader/hd-plugin-loader-qt.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/qtpluginloader/hd-plugin-loader-qt.c b/qtpluginloader/hd-plugin-loader-qt.c index 912d6c2..ebdd0ca 100644 --- a/qtpluginloader/hd-plugin-loader-qt.c +++ b/qtpluginloader/hd-plugin-loader-qt.c @@ -44,6 +44,8 @@ #include "hd-plugin-loader-qt.h" #include <unistd.h> +#include <sys/types.h> +#include <sys/wait.h> #include <X11/Xlib.h> #include <gdk/gdkx.h> @@ -62,6 +64,8 @@ struct _QtAbstractHomeItemPrivate { + pid_t pid; // process ID of child process + GIOChannel *gio_read; gchar realized; @@ -76,6 +80,7 @@ qt_abstract_home_item_init (QtAbstractHomeItem *object) object->priv = QT_ABSTRACT_HOME_ITEM_GET_PRIVATE (object); QtAbstractHomeItemPrivate *priv = object->priv; + priv->pid = 0; priv->gio_read = NULL; priv->realized = FALSE; @@ -121,6 +126,9 @@ qt_abstract_home_item_gio_in (GIOChannel *gio, GIOCondition condition, gpointer gtk_main_do_event (gdk_delete_event); gdk_event_free (gdk_delete_event); + /* now reap the child process */ + QtAbstractHomeItem *object = (QtAbstractHomeItem *)data; + waitpid( object->priv->pid, NULL, WNOHANG ); return FALSE; } @@ -159,11 +167,11 @@ qt_abstract_home_item_execute (QtAbstractHomeItem *object) return qt_abstract_home_item_error_new("Creating pipe failed."); /* --- Fork and exec the new application */ - pid_t pid = fork(); - if (pid < 0) { - return qt_abstract_home_item_error_new("Unable do fork new process."); + priv->pid = fork(); + if (priv->pid < 0) { + return qt_abstract_home_item_error_new("Unable to fork new process."); - } else if (pid) { + } else if (priv->pid) { /* I am the original process */ close( qtToGtkPipe[1] ); |