[pkg-fso-commits] [SCM] Automatic Display Manager branch, bug540201, updated. debian/0.6-1-52-g7a268a7

Enrico Zini enrico at enricozini.org
Wed Jul 6 19:13:33 UTC 2011


The following commit has been merged in the bug540201 branch:
commit fe9204264219300e927739fec2b15d738f126871
Author: Enrico Zini <enrico at enricozini.org>
Date:   Wed Jul 6 17:57:37 2011 +0200

    Wait for X server and X session after stopping them

diff --git a/dm.c b/dm.c
index 2b31ea8..5a482d2 100644
--- a/dm.c
+++ b/dm.c
@@ -274,9 +274,7 @@ int nodm_display_manager_wait_restart_loop(struct nodm_display_manager* dm)
                 if (r != -1)
                     break;
                 else if (errno == EINTR)
-                {
                     tosleep = remaining;
-                }
                 else
                 {
                     log_warn("sleep aborted: %m (ignoring error");
diff --git a/nodm.c b/nodm.c
index d497012..9118e4d 100644
--- a/nodm.c
+++ b/nodm.c
@@ -76,7 +76,7 @@ int main (int argc, char **argv)
         {"nested",  no_argument,       &opt_nested, 1},
         {0, 0, 0, 0}
     };
-    // TODO: implement --no-syslog --no-stderr and the like
+    // TODO: more output control, such as something like --quiet, --no-syslog, --no-stderr
 
     // Parse command line options
     while (1)
diff --git a/xserver.c b/xserver.c
index fed91bb..cbffcc1 100644
--- a/xserver.c
+++ b/xserver.c
@@ -205,12 +205,24 @@ cleanup:
 
 int nodm_xserver_stop(struct nodm_xserver* srv)
 {
+    int res = E_SUCCESS;
     if (srv->pid > 0)
     {
         kill(srv->pid, SIGTERM);
         kill(srv->pid, SIGCONT);
+        while (true)
+        {
+            int status;
+            if (waitpid(srv->pid, &status, 0) == -1)
+            {
+                if (errno == EINTR)
+                    continue;
+                if (errno != ECHILD)
+                    res = E_OS_ERROR;
+            }
+            break;
+        }
     }
-    // TODO: wait
     srv->pid = -1;
 
     if (srv->windowpath != NULL)
@@ -218,7 +230,7 @@ int nodm_xserver_stop(struct nodm_xserver* srv)
         free(srv->windowpath);
         srv->windowpath = NULL;
     }
-    return E_SUCCESS;
+    return res;
 }
 
 static int xopendisplay_error_handler(Display* dpy)
diff --git a/xsession.c b/xsession.c
index 0144be2..45cfcdb 100644
--- a/xsession.c
+++ b/xsession.c
@@ -27,6 +27,7 @@
 #include <signal.h>
 #include <pwd.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -127,14 +128,27 @@ int nodm_xsession_start(struct nodm_xsession* s, struct nodm_xserver* srv)
 
 int nodm_xsession_stop(struct nodm_xsession* s)
 {
+    int res = E_SUCCESS;
+
     if (s->pid > 0)
     {
         kill(s->pid, SIGTERM);
         kill(s->pid, SIGCONT);
+        while (true)
+        {
+            int status;
+            if (waitpid(s->pid, &status, 0) == -1)
+            {
+                if (errno == EINTR)
+                    continue;
+                if (errno != ECHILD)
+                    res = E_OS_ERROR;
+            }
+            break;
+        }
     }
-    // TODO: wait
     s->pid = -1;
-    return E_SUCCESS;
+    return res;
 }
 
 void nodm_xsession_dump_status(struct nodm_xsession* s)

-- 
Automatic Display Manager



More information about the pkg-fso-commits mailing list