[systemd-devel] [PATCH 2/4] special shutdown targets will now cause manager to exit.

Gustavo Sverzut Barbieri barbieri at profusion.mobi
Fri Oct 1 07:44:18 PDT 2010


On Fri, Oct 1, 2010 at 10:54 AM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Fri, 01.10.10 02:28, Gustavo Sverzut Barbieri (barbieri at profusion.mobi) wrote:
>
>> +++ b/src/target.c
>> @@ -172,6 +172,14 @@ static int target_start(Unit *u) {
>>          assert(t->state == TARGET_DEAD);
>>
>>          target_set_state(t, TARGET_ACTIVE);
>> +
>> +        if (unit_has_name(u, SPECIAL_REBOOT_TARGET))
>> +                t->meta.manager->exit_code = MANAGER_REBOOT;
>> +        else if (unit_has_name(u, SPECIAL_POWEROFF_TARGET))
>> +                t->meta.manager->exit_code = MANAGER_POWEROFF;
>> +        else if (unit_has_name(u, SPECIAL_HALT_TARGET))
>> +                t->meta.manager->exit_code = MANAGER_HALT;
>> +
>>          return 0;
>>  }
>
> Please don't do this. Instead just place a normal service in these
> targets that uses "systemctl" or "kill" to ask PID 1 to do the right
> operation here...

yes, this is hackish, but your solution does need some replication as
I need to have it specifically for dbus, then signals (which to use?),
then socket then any other command interface we choose. At least this
is ugly but at a central place that always work.

another option is to have one more entry in target units that specify
the manager exit_code. Then the unit parser converts it to
ManagerExitCode and if != _MANAGER_EXIT_CODE_INVALID then it applies
to t->meta.manager->exit_code. It would be more generic, but really,
we already named the others "special targets". If you want I can make
this conversion to ManagerExitCode  at parse time.

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: barbieri at gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202


More information about the systemd-devel mailing list