summaryrefslogtreecommitdiff
path: root/src/manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-05-24 22:31:38 +0200
committerLennart Poettering <lennart@poettering.net>2010-05-24 22:32:44 +0200
commita1b256b0b562481404bda8304e04dee7d7d5e7c9 (patch)
tree24ef1cba86f0a789d5ecc8fe5c19cbd8b09ca8f0 /src/manager.c
parent683f468c54a81fd4084a2ba1082025959cd3c7d1 (diff)
unit: introduce exit.service for exiting from session instances
Diffstat (limited to 'src/manager.c')
-rw-r--r--src/manager.c21
1 files changed, 14 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)