[Xfce-bugs] [Bug 10046] New: Use g_child_watch_add instead of waitpid
bugzilla-daemon at xfce.org
bugzilla-daemon at xfce.org
Mon Apr 29 13:44:40 CEST 2013
https://bugzilla.xfce.org/show_bug.cgi?id=10046
Bug ID: 10046
Summary: Use g_child_watch_add instead of waitpid
Classification: Xfce
Product: Xfce4-session
Version: Unspecified
Hardware: Other
OS: Linux
Status: NEW
Severity: enhancement
Priority: Medium
Component: General
Assignee: xfce-bugs at xfce.org
Reporter: natanael.copa at gmail.com
QA Contact: bjt23 at cornell.edu
CC: benny at xfce.org, nick at xfce.org
Created attachment 5014
--> https://bugzilla.xfce.org/attachment.cgi?id=5014&action=edit
0001-Use-g_child_watch_add-instead-of-waitpid.patch
>From 0e4d3c7d084d77e9d429e40622619c6dc0f5c2a8 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa at alpinelinux.org>
Date: Wed, 10 Apr 2013 20:48:40 +0200
Subject: [PATCH] Use g_child_watch_add instead of waitpid
This reduces code size.
Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
---
xfce4-session/xfsm-compat-kde.c | 27 +++++----------------------
1 file changed, 5 insertions(+), 22 deletions(-)
diff --git a/xfce4-session/xfsm-compat-kde.c b/xfce4-session/xfsm-compat-kde.c
index b51387e..ce4b134 100644
--- a/xfce4-session/xfsm-compat-kde.c
+++ b/xfce4-session/xfsm-compat-kde.c
@@ -51,27 +51,11 @@
static gboolean kde_compat_started = FALSE;
-static gboolean
-run_timeout (gpointer user_data)
+static void
+run_watcher (GPid pid, gint status, gpointer user_data)
{
- int status;
- int result;
- pid_t pid = *((pid_t *) user_data);
-
- result = waitpid (pid, &status, WNOHANG);
-
- if (result == pid)
- {
- gtk_main_quit ();
- }
- else if (result == -1)
- {
- g_warning ("Failed to wait for process %d: %s",
- (int)pid, g_strerror (errno));
- gtk_main_quit ();
- }
-
- return TRUE;
+ g_spawn_close_pid(pid);
+ gtk_main_quit ();
}
@@ -98,9 +82,8 @@ run (const gchar *command)
G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
NULL, NULL, &pid, &error))
{
- guint id = g_timeout_add (300, run_timeout, &pid);
+ g_child_watch_add (pid, run_watcher, NULL);
gtk_main ();
- g_source_remove (id);
}
else
{
--
1.8.2.1
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Xfce-bugs
mailing list