From 33690118e24b9c5dd5bb5472306855f4bf022270 Mon Sep 17 00:00:00 2001 From: Ralf Engels Date: Mon, 28 Jun 2010 14:26:30 +0200 Subject: Reap child processes to prevent zombies --- qtpluginloader/hd-plugin-loader-qt.c | 16 ++++++++++++---- 1 file 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 +#include +#include #include #include @@ -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] ); -- cgit v1.2.3