Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -227,7 +229,6 @@ int nodm_display_manager_wait(struct nodm_display_manager* dm, int* session_stat
}

cleanup:
shutdown_quit_notification(&origset);
return res;
}

Expand Down Expand Up @@ -352,7 +353,6 @@ static int interruptible_sleep(int seconds)
}
}

shutdown_quit_notification(&origset);
return res;
}

Expand All @@ -369,13 +369,17 @@ 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:
break;
case E_SESSION_DIED:
break;
default:

return res;
}

Expand Down