[Xfce4-commits] r25744 - in xfce4-panel/trunk: . plugins/launcher
Nick Schermer
nick at xfce.org
Tue May 22 20:20:49 CEST 2007
Author: nick
Date: 2007-05-22 18:20:49 +0000 (Tue, 22 May 2007)
New Revision: 25744
Modified:
xfce4-panel/trunk/ChangeLog
xfce4-panel/trunk/configure.in.in
xfce4-panel/trunk/plugins/launcher/launcher-exec.c
Log:
* configure.in.in, plugins/launcher/launcher-exec.c: Avoid zombie processes.
Modified: xfce4-panel/trunk/ChangeLog
===================================================================
--- xfce4-panel/trunk/ChangeLog 2007-05-22 18:12:32 UTC (rev 25743)
+++ xfce4-panel/trunk/ChangeLog 2007-05-22 18:20:49 UTC (rev 25744)
@@ -1,3 +1,7 @@
+2007-05-22 12:33 nick
+
+ * configure.in.in, plugins/launcher/launcher-exec.c: Avoid zombie processes.
+
2007-03-27 16:31 nick
* Backport trunk
Modified: xfce4-panel/trunk/configure.in.in
===================================================================
--- xfce4-panel/trunk/configure.in.in 2007-05-22 18:12:32 UTC (rev 25743)
+++ xfce4-panel/trunk/configure.in.in 2007-05-22 18:20:49 UTC (rev 25744)
@@ -84,7 +84,7 @@
AC_HEADER_STDC()
AC_CHECK_HEADERS([stdlib.h unistd.h locale.h stdio.h fcntl.h errno.h \
math.h signal.h stddef.h sys/wait.h sys/stat.h \
- sys/type.h sys/mman.h time.h string.h])
+ sys/type.h sys/types.h sys/mman.h sys/wait.h time.h string.h])
dnl ************************************
dnl *** Check for standard functions ***
Modified: xfce4-panel/trunk/plugins/launcher/launcher-exec.c
===================================================================
--- xfce4-panel/trunk/plugins/launcher/launcher-exec.c 2007-05-22 18:12:32 UTC (rev 25743)
+++ xfce4-panel/trunk/plugins/launcher/launcher-exec.c 2007-05-22 18:20:49 UTC (rev 25744)
@@ -26,6 +26,15 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
#include "launcher.h"
#include "launcher-exec.h"
@@ -159,6 +168,7 @@
launcher_exec_startup_timeout_destroy (gpointer data)
{
LauncherStartupData *startup_data = data;
+ gint status;
g_return_if_fail (startup_data->sn_launcher == NULL);
@@ -180,19 +190,34 @@
gint status,
gpointer data)
{
- LauncherStartupData *startup_data = data;
+ LauncherStartupData *startup_data = data;
+ gint ret, serrno;
- g_return_if_fail (startup_data->sn_launcher != NULL);
- g_return_if_fail (startup_data->watch_id != 0);
- g_return_if_fail (startup_data->pid == pid);
+ g_return_if_fail (startup_data->sn_launcher != NULL);
+ g_return_if_fail (startup_data->watch_id != 0);
+ g_return_if_fail (startup_data->pid == pid);
- /* abort the startup notification (application exited) */
- sn_launcher_context_complete (startup_data->sn_launcher);
- sn_launcher_context_unref (startup_data->sn_launcher);
- startup_data->sn_launcher = NULL;
+ /* abort the startup notification (application exited) */
+ sn_launcher_context_complete (startup_data->sn_launcher);
+ sn_launcher_context_unref (startup_data->sn_launcher);
+ startup_data->sn_launcher = NULL;
- /* cancel the startup notification timeout */
- g_source_remove (startup_data->timeout_id);
+ /* avoid zombie processes */
+ serrno = errno;
+ while (1)
+ {
+ /* get the child process state without hanging */
+ ret = waitpid (WAIT_ANY, NULL, WNOHANG);
+
+ /* exit if there is nothing to wait for */
+ if (ret == 0 || ret < 0)
+ break;
+ }
+ errno = serrno;
+
+ /* cancel the startup notification timeout */
+ /* this will also activate the timeout_destroy function */
+ g_source_remove (startup_data->timeout_id);
}
#endif
More information about the Xfce4-commits
mailing list