Re: Generic interrupt command?

From: John O'Meara <john.fr.omeara_at_gmail.com>
Date: Tue, 5 Feb 2019 09:16:55 -0500

On Tue, Feb 5, 2019, 2:20 AM Laurent Bercot <ska-supervision_at_skarnet.org>
wrote:

> >Be careful, though. If the service is down, kill will use -1 for the PID,
> >and will probably signal everything in your system except PID 1.
>
> That's a good point. Should s6-svstat use 0 as the "service is down"
> pid value instead, to avoid this ?
>

0 behaves better for this use case, but can still produce unexpected
behavior.

The construction "echo 0 | xargs kill -STOP" for example leaves behind a
paused background task that needs to be cleaned by hand.

The construction "kill -STOP $(echo 0)" hangs the terminal until someone
resumes the user's shell.

Most other "kill -whatever $(echo 0)" results in the shell exiting and the
user having to log back in.

So, 0 is a lot better than -1, but still not great.

Not outputting anything causes kill (on my system at least) to exit non 0
and give some diagnostic ("`' not a pid or valid pid spec", "you need to
specify whom to kill", or the usage message). That's nice, but would
probably break other scripting that expects a value, especially for
s6-svstat showing multiple fields.

I can't think of a safe and simple way to do this. For example, we could
suggest people do something like this (based on Roger Pate's post):

   pid=$(s6-svstat -p /my/service) && [ "$pid" -ne -1 ] && kill -SIGNAL $pid

but that's a lot of typing and requires that people see and remember the
suggestion, so not quite simple :-/

-- 
John O'Meara
>
Received on Tue Feb 05 2019 - 14:16:55 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:19 UTC