bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/misc/entrance.git/commit/?id=1be65edee756d4e35d727a2ef57c965246b9fd4e

commit 1be65edee756d4e35d727a2ef57c965246b9fd4e
Author: Marcel Hollerbach <[email protected]>
Date:   Thu Jan 23 21:44:01 2014 +0100

    - Added feature a option called fastexit, if this is set entrance will
      quit in any way, if not entrance just quits if the DE exits with an
      error.
    - Fixed the issue that entrance is not restarting after closing the
      logged in session, this is done by NOT exitings if a user is logged in
      allready, the pam session is closed, Xserver is quit, so entrance can 
restart.
---
 src/daemon/entrance.c      | 16 +++++++++++++---
 src/daemon/entrance_wait.c | 18 +++++++++++++++---
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/daemon/entrance.c b/src/daemon/entrance.c
index 7f18c38..6513a87 100644
--- a/src/daemon/entrance.c
+++ b/src/daemon/entrance.c
@@ -195,6 +195,10 @@ static const Ecore_Getopt options =
    {
       ECORE_GETOPT_STORE_TRUE('n', "nodaemon", "Don't daemonize."),
       ECORE_GETOPT_STORE_TRUE('t', "test", "run in test mode."),
+      ECORE_GETOPT_STORE_TRUE('e', "fastexit", "Will change the way entrance \
+handles the exit of the created session.\n If set, entrance will exit if the 
session \
+quits.\n If not, entrance will restart if the session is quit because of an 
error, \
+or if the environment variable ENTRANCE_RESTART is set."),
       ECORE_GETOPT_STORE_TRUE('x', "xephyr", "run in test mode and use 
Xephyr."),
       ECORE_GETOPT_HELP ('h', "help"),
       ECORE_GETOPT_VERSION('V', "version"),
@@ -212,12 +216,14 @@ main (int argc, char ** argv)
    char *dname;
    char *entrance_user = NULL;
    unsigned char nodaemon = 0;
+   unsigned char fastexit = 0;
    unsigned char quit_option = 0;
 
    Ecore_Getopt_Value values[] =
      {
         ECORE_GETOPT_VALUE_BOOL(nodaemon),
         ECORE_GETOPT_VALUE_BOOL(_testing),
+        ECORE_GETOPT_VALUE_BOOL(fastexit),
         ECORE_GETOPT_VALUE_BOOL(_xephyr),
         ECORE_GETOPT_VALUE_BOOL(quit_option),
         ECORE_GETOPT_VALUE_BOOL(quit_option),
@@ -244,6 +250,12 @@ main (int argc, char ** argv)
    if (!_xephyr && getenv("ENTRANCE_XEPHYR"))
      _xephyr = EINA_TRUE;
 
+   if (fastexit)
+     {
+        putenv(strdup("ENTRANCE_FAST_QUIT=1"));
+        PT("Fast exit enabled !\n");
+     }
+
    if (_xephyr)
      {
         _testing = EINA_TRUE;
@@ -321,9 +333,7 @@ main (int argc, char ** argv)
              entrance_close_log();
              exit(0);
           }
-        entrance_close_log();
-        PT("Nice to see you again.\n");
-        exit(1);
+        PT("Nice to see you again. Entrance will restart.\n");
      }
    PT("Welcome\n");
    ecore_init();
diff --git a/src/daemon/entrance_wait.c b/src/daemon/entrance_wait.c
index a15e167..603a06d 100644
--- a/src/daemon/entrance_wait.c
+++ b/src/daemon/entrance_wait.c
@@ -1,5 +1,6 @@
 #include <sys/wait.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
 
@@ -31,13 +32,15 @@ int
 main (int argc __UNUSED__, char **argv __UNUSED__)
 {
    int status = 0;
-   char *pid;
+   char *pid, *exit_policy;
    struct sigaction action;
 
    pid_t rpid;
    pid = getenv("ENTRANCE_XPID");
    if (!pid) return -1;
    _x_pid = atoi(pid);
+   
+   exit_policy = getenv("ENTRANCE_FAST_QUIT");
 
    action.sa_sigaction = _entrance_wait_action;
    action.sa_flags = SA_RESTART | SA_SIGINFO;
@@ -61,8 +64,17 @@ main (int argc __UNUSED__, char **argv __UNUSED__)
      }
    if (_x_pid == rpid)
      {
-        if (WIFEXITED(status) && WEXITSTATUS(status))
-          setenv("ENTRANCE_QUIT", "1", 1);
+        if (exit_policy)
+          {
+             setenv("ENTRANCE_QUIT", "1", 1);
+          }
+        else
+          {
+             if ( WIFEXITED(status) && WEXITSTATUS(status))
+               {
+                  setenv("ENTRANCE_QUIT", "1", 1);
+               }
+          }
         execlp(PACKAGE_SBIN_DIR"/entrance", PACKAGE_SBIN_DIR"/entrance", 
"--nodaemon", NULL);
      }
    return -1;

-- 


Reply via email to