diff --git a/README.md b/README.md index e1273d2..d1a68d9 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ of least surprise. This is what is offered: - nodm performs VT allocation, looking for a free virtual terminal in which to run X and keeping it allocated across X restarts. - X is started (by default, /usr/bin/X) - - once the X esrver is ready to accept connections, the X session is set up: + - once the X server is ready to accept connections, the X session is set up: - the DISPLAY and WINDOWPATH environment variables are set - the session is wrapped in a PAM session, which sets up the user environment diff --git a/dm.c b/dm.c index b5434cc..eb68c42 100644 --- a/dm.c +++ b/dm.c @@ -137,6 +137,7 @@ int nodm_display_manager_stop(struct nodm_display_manager* dm) } // Signal handler for wait loop +static int setup_quit_notifications_done = 0; static int quit_signal_caught = 0; static void catch_signals (int sig) { @@ -145,6 +146,13 @@ static void catch_signals (int sig) static int setup_quit_notification(sigset_t* origset) { + if (quit_signal_caught) + return E_USER_QUIT; + + if (setup_quit_notifications_done) + return E_SUCCESS; + + setup_quit_notifications_done = 1; /* Reset caught signal flag */ quit_signal_caught = 0; @@ -169,12 +177,6 @@ static int setup_quit_notification(sigset_t* origset) return E_SUCCESS; } -static void shutdown_quit_notification(const sigset_t* origset) -{ - if (sigprocmask(SIG_SETMASK, origset, NULL) == -1) - log_err("sigprocmask error: %m"); -} - int nodm_display_manager_wait(struct nodm_display_manager* dm, int* session_status) { int res = E_SUCCESS; @@ -227,7 +229,6 @@ int nodm_display_manager_wait(struct nodm_display_manager* dm, int* session_stat } cleanup: - shutdown_quit_notification(&origset); return res; } @@ -352,7 +353,6 @@ static int interruptible_sleep(int seconds) } } - shutdown_quit_notification(&origset); return res; } @@ -369,6 +369,9 @@ int nodm_display_manager_wait_restart_loop(struct nodm_display_manager* dm) time_t end = time(NULL); nodm_display_manager_stop(dm); + if (quit_signal_caught) + res = E_USER_QUIT; + switch (res) { case E_X_SERVER_DIED: @@ -376,6 +379,7 @@ int nodm_display_manager_wait_restart_loop(struct nodm_display_manager* dm) case E_SESSION_DIED: break; default: + return res; }