[systemd-devel] [PATCH] service: add support for reboot argument when triggered by StartLimitAction=

Lennart Poettering lennart at poettering.net
Mon Mar 24 11:52:25 PDT 2014


On Fri, 21.03.14 15:34, Michael Olbrich (m.olbrich at pengutronix.de) wrote:

> When rebooting with systemctl, an optional argument can be passed to the
> reboot system call. This makes it possible the specify the argument in a
> service file and use it when the service triggers a restart.
> This is useful to distinguish between manual reboots and reboots caused by
> failing services.

Hmm, I am a bit concerned about failed boots where the param then stays
around, and is still applied to a subsequent attempt, even though not
specified anymore.

I'd thus prefer if we could explicitly unlink the file should no reboot
param be specified. And that should be treated the same for systemctl as
for this code, which means we probably should have a common function for
this in util.c that deletes the file on NULL and creates it if non-NULL,
if you follow what I mean. That function should then simply be used by
both service.c and systemctl.c.

> diff --git a/src/core/service.h b/src/core/service.h
> index 1992926..fd05e9b 100644
> --- a/src/core/service.h
> +++ b/src/core/service.h
> @@ -189,6 +189,7 @@ struct Service {
>  
>          RateLimit start_limit;
>          StartLimitAction start_limit_action;
> +        char *reboot_arg;
>  
>          UnitRef accept_socket;

This needs some code to free the string again, in service_done().

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list