Re: How to supervise an early process

From: Charles Duffy <>
Date: Sun, 19 Jun 2016 16:31:13 +0000

Hmm. I'd actually tend to suggest using a lockfile (and then looking for
programs with a handle on that file to kill with fuser or a like tool)
rather than the error-prone practice of grepping ps, and the
similarly-error-prone practice of using killall. Granted, if starting in
the initramfs, that means a bit of care (ie. to already mount whichever
filesystem one will be creating the lockfile on before pivot, or to create
a tmpfs filesystem or such which can be moved into the new tree), but I'd
argue it to be worthwhile.

On Sun, Jun 19, 2016 at 10:57 AM Steve Litt <>

> Hi all,
> A big objection to most supervision type init systems is that for a
> given process you must choose between early, like run from the rc
> script(s) preceding running of the supervisor, and respawning
> supervision.
> I just thought of a theoretical hack to have both.
> Symlink to give the executable a new name.
> ln -s myapp myapp_sym
> Run myapp_sym as early as you want in the rc file. Heck, run it in
> the initramfs for all I care, and let it switch_root over. Then, in the
> run script for any supervision suite, do this:
> ===========================================
> #!/bin/sh
> if ps ax | grep myapp_sym; then
> killall myapp_sym
> fi
> exec myapp
> ===========================================
> Obviously, for some apps, you'll need to shut down a little more
> gracefully than killall, but whatever way you need to shut down, you
> just put it in the if statement or in a shellscript called from
> within the if statement.
> This should work on daemontools, daemontools-encore, runit and s6. It
> might run on more, but those four are the only ones I've used.
> One of the outstanding benefits of supervision suites is how malleable
> they are with a little imagination.
> Thanks,
> SteveT
> Steve Litt
> June 2016 featured book: Troubleshooting: Why Bother?
Received on Sun Jun 19 2016 - 16:31:13 UTC

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