From a40eb73224e237f758d38847ae216c019425ebac Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 3 Jul 2010 19:48:33 +0200 Subject: unit: add DefaultDependencies= setting In order to simplify writing of unit files introduce default dependencies that are added to all units unless explictly disabled in a unit. This option can be switched off for select units that are involved in early boot-up ot late system shutdown, This should simplify service files for most normal daemons, but breaks existing service files for software involved in early boot (notably udev), which need to be updated for a DefaultDependencies=no setting) --- src/timer.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/timer.c') diff --git a/src/timer.c b/src/timer.c index f0005f55ce..e3c916bb0f 100644 --- a/src/timer.c +++ b/src/timer.c @@ -25,6 +25,7 @@ #include "unit-name.h" #include "timer.h" #include "dbus-timer.h" +#include "special.h" static const UnitActiveState state_translation_table[_TIMER_STATE_MAX] = { [TIMER_DEAD] = UNIT_INACTIVE, @@ -89,6 +90,11 @@ static int timer_load(Unit *u) { if ((r = unit_add_dependency(u, UNIT_BEFORE, t->unit, true)) < 0) return r; + + /* Timers shouldn't stay around on shutdown */ + if (t->meta.default_dependencies) + if ((r = unit_add_two_dependencies_by_name(u, UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true)) < 0) + return r; } return timer_verify(t); -- cgit v1.2.3-54-g00ecf