summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2013-02-28 00:01:10 +0100
committerMichal Schmidt <mschmidt@redhat.com>2013-02-28 02:24:01 +0100
commit7ed9f6cd785634dd093e1b1550c3c6183177abf6 (patch)
tree266293630d3cb0a0928a7d4159b55694af2ef831 /src/core/unit.c
parent6ac8fdc9554a40024827ad9f64d02b4d8d2ab8ba (diff)
core: count active units that may mind our printing to /dev/console
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index f8a913e39a..e2c06ae8b6 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1357,6 +1357,21 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
if (UNIT_IS_INACTIVE_OR_FAILED(ns))
cgroup_bonding_trim_list(u->cgroup_bondings, true);
+ if (UNIT_IS_INACTIVE_OR_FAILED(os) != UNIT_IS_INACTIVE_OR_FAILED(ns)) {
+ ExecContext *ec = unit_get_exec_context(u);
+ if (ec && exec_context_may_touch_console(ec)) {
+ /* XXX The counter may get out of sync if the admin edits
+ * TTY-related unit file properties and issues a daemon-reload
+ * while the unit is active. No big deal though, because
+ * it influences only the printing of boot/shutdown
+ * status messages. */
+ if (UNIT_IS_INACTIVE_OR_FAILED(ns))
+ m->n_on_console--;
+ else
+ m->n_on_console++;
+ }
+ }
+
if (u->job) {
unexpected = false;