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 #include +#include #include #include @@ -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;