diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-05-24 22:31:38 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-05-24 22:32:44 +0200 |
commit | a1b256b0b562481404bda8304e04dee7d7d5e7c9 (patch) | |
tree | 24ef1cba86f0a789d5ecc8fe5c19cbd8b09ca8f0 /src | |
parent | 683f468c54a81fd4084a2ba1082025959cd3c7d1 (diff) |
unit: introduce exit.service for exiting from session instances
Diffstat (limited to 'src')
-rw-r--r-- | src/manager.c | 21 | ||||
-rw-r--r-- | src/manager.h | 1 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/manager.c b/src/manager.c index 2a773c6dbb..933dd5064f 100644 --- a/src/manager.c +++ b/src/manager.c @@ -1791,11 +1791,13 @@ static int manager_dispatch_sigchld(Manager *m) { return 0; } -static void manager_start_target(Manager *m, const char *name) { +static int manager_start_target(Manager *m, const char *name) { int r; if ((r = manager_add_job_by_name(m, JOB_START, name, JOB_REPLACE, true, NULL)) < 0) log_error("Failed to enqueue %s job: %s", name, strerror(-r)); + + return r; } static int manager_process_signal_fd(Manager *m) { @@ -1824,14 +1826,14 @@ static int manager_process_signal_fd(Manager *m) { break; case SIGTERM: - if (m->running_as == MANAGER_INIT) + if (m->running_as == MANAGER_INIT) { /* This is for compatibility with the * original sysvinit */ m->exit_code = MANAGER_REEXECUTE; - else - m->exit_code = MANAGER_EXIT; + break; + } - return 0; + /* Fall through */ case SIGINT: if (m->running_as == MANAGER_INIT) { @@ -1839,8 +1841,13 @@ static int manager_process_signal_fd(Manager *m) { break; } - m->exit_code = MANAGER_EXIT; - return 0; + /* Run the exit target if there is one, if not, just exit. */ + if (manager_start_target(m, SPECIAL_EXIT_SERVICE) < 0) { + m->exit_code = MANAGER_EXIT; + return 0; + } + + break; case SIGWINCH: if (m->running_as == MANAGER_INIT) diff --git a/src/manager.h b/src/manager.h index 22ba04f799..210e66053c 100644 --- a/src/manager.h +++ b/src/manager.h @@ -109,6 +109,7 @@ struct Watch { #define SPECIAL_MAIL_TRANSFER_AGENT_TARGET "mail-transfer-agent.target" /* Debian's $mail-{transport|transfer-agent */ #define SPECIAL_BASIC_TARGET "basic.target" #define SPECIAL_RESCUE_TARGET "rescue.target" +#define SPECIAL_EXIT_SERVICE "exit.service" #ifndef SPECIAL_DBUS_SERVICE #define SPECIAL_DBUS_SERVICE "dbus.service" |