summaryrefslogtreecommitdiff
path: root/src/core/service.c
diff options
context:
space:
mode:
authorOlivier Brunel <jjk@jjacky.com>2013-11-14 15:52:54 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-11-16 12:08:11 -0500
commit9cd861842ccb07372fbd665f2e6c054daaedacb4 (patch)
treea724b96b5aa369b958bd3d3703fc356ecbb1625f /src/core/service.c
parentad929fe19673ff7135d570f458edef755ec34410 (diff)
Fix RemainAfterExit services keeping a hold on console
When a service exits succesfully and has RemainAfterExit set, its hold on the console (in m->n_on_console) wasn't released since the unit state didn't change.
Diffstat (limited to 'src/core/service.c')
-rw-r--r--src/core/service.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/service.c b/src/core/service.c
index 3da32a1621..c0ee1140a8 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1519,6 +1519,22 @@ static void service_set_state(Service *s, ServiceState state) {
if (state == SERVICE_EXITED && UNIT(s)->manager->n_reloading <= 0)
unit_destroy_cgroup(UNIT(s));
+ /* For remain_after_exit services, let's see if we can "release" the
+ * hold on the console, since unit_notify() only does that in case of
+ * change of state */
+ if (state == SERVICE_EXITED && s->remain_after_exit &&
+ UNIT(s)->manager->n_on_console > 0) {
+ ExecContext *ec = unit_get_exec_context(UNIT(s));
+ if (ec && exec_context_may_touch_console(ec)) {
+ Manager *m = UNIT(s)->manager;
+
+ m->n_on_console --;
+ if (m->n_on_console == 0)
+ /* unset no_console_output flag, since the console is free */
+ m->no_console_output = false;
+ }
+ }
+
if (old_state != state)
log_debug_unit(UNIT(s)->id,
"%s changed %s -> %s", UNIT(s)->id,