[gdm] Terminate subprocesses after the slave dies



commit 712cd8d8faa05151f979ac3baf53868bae78c7f8
Author: William Jon McCann <jmccann redhat com>
Date:   Tue Jun 15 12:00:25 2010 -0400

    Terminate subprocesses after the slave dies
    
    This will help prevent leaving the system in an inconsistent state.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=621661

 daemon/gdm-server.c             |    8 ++++++++
 daemon/gdm-session-worker-job.c |    7 +++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
index 840a030..dbe29ef 100644
--- a/daemon/gdm-server.c
+++ b/daemon/gdm-server.c
@@ -33,6 +33,9 @@
 #include <grp.h>
 #include <signal.h>
 #include <sys/resource.h>
+#if defined (__linux__)
+#include <sys/prctl.h>
+#endif
 
 #include <glib.h>
 #include <glib/gi18n.h>
@@ -464,6 +467,11 @@ server_child_setup (GdmServer *server)
         sigemptyset (&mask);
         sigprocmask (SIG_SETMASK, &mask, NULL);
 
+        /* Terminate the process when the parent dies */
+#if defined (__linux__)
+        prctl (PR_SET_PDEATHSIG, SIGTERM);
+#endif
+
         if (server->priv->priority != 0) {
                 if (setpriority (PRIO_PROCESS, 0, server->priv->priority)) {
                         g_warning (_("%s: Server priority couldn't be set to %d: %s"),
diff --git a/daemon/gdm-session-worker-job.c b/daemon/gdm-session-worker-job.c
index 633d6e2..149d83a 100644
--- a/daemon/gdm-session-worker-job.c
+++ b/daemon/gdm-session-worker-job.c
@@ -32,6 +32,9 @@
 #include <pwd.h>
 #include <grp.h>
 #include <signal.h>
+#if defined (__linux__)
+#include <sys/prctl.h>
+#endif
 
 #include <glib.h>
 #include <glib/gi18n.h>
@@ -84,6 +87,10 @@ G_DEFINE_TYPE (GdmSessionWorkerJob, gdm_session_worker_job, G_TYPE_OBJECT)
 static void
 session_worker_job_child_setup (GdmSessionWorkerJob *session_worker_job)
 {
+        /* Terminate the process when the parent dies */
+#if defined (__linux__)
+        prctl (PR_SET_PDEATHSIG, SIGTERM);
+#endif
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]