[systemd-devel] [PATCH v2] gnome-ask-password-agent: do not double fork spawned process

Michael Laß bevan at bi-co.net
Tue Aug 13 21:46:24 PDT 2013


pkexec does not like being a lonely child:
"Refusing to render service to dead parents."

Do not double fork when spawning the process by using the DO_NOT_REAP_CHILD
flag. Clean up manually using a child watch.
---
 src/gnome-ask-password-agent.vala | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gnome-ask-password-agent.vala b/src/gnome-ask-password-agent.vala
index 0f6284d..8a5346d 100644
--- a/src/gnome-ask-password-agent.vala
+++ b/src/gnome-ask-password-agent.vala
@@ -213,6 +213,7 @@ public class MyStatusIcon : StatusIcon {
                     result == ResponseType.DELETE_EVENT)
                         return;
 
+                Pid child_pid;
                 int to_process;
 
                 try {
@@ -220,12 +221,15 @@ public class MyStatusIcon : StatusIcon {
                                         null,
                                         { "/usr/bin/pkexec", "/lib/systemd/systemd-reply-password", result == ResponseType.OK ? "1" : "0", socket },
                                         null,
-                                        0,
-                                        null,
+                                        SpawnFlags.DO_NOT_REAP_CHILD,
                                         null,
+                                        out child_pid,
                                         out to_process,
                                         null,
                                         null);
+                        ChildWatch.add(child_pid, (pid, status) => {
+                                Process.close_pid(pid);
+                        });
 
                         OutputStream stream = new UnixOutputStream(to_process, true);
 #if VALA_0_12
-- 
1.8.3.4



More information about the systemd-devel mailing list