[arch-dev-public] [arch-general] Adopting start-stop-daemon in archlinux

Tom Gundersen teg at jklm.no
Thu Sep 8 12:01:48 EDT 2011

Hi guys,

On Thu, Sep 8, 2011 at 1:08 PM, Thomas Bächler <thomas at archlinux.org> wrote:
> Am 08.09.2011 12:08, schrieb Clemens Fruhwirth:
>> If you use Debian, you might have come across start-stop-daemon. It's
>> part of the dpkg package and encapsulates all the knowledge, they
>> learnt when dealing with starting and stopping daemons. It has plenty
>> of features ranging from:
>> * handling pidfiles more intimately (checking the pid files content,
>> verifying that the pid given actually is the executable in question)
>> * changing UID/GID
>> * chrooting, nice-ing
>> * retry starting if daemon dies
>> * creating pid files when the process doesn't do it, etc, etc.
>> curl http://clemens.endorphin.org/start-stop-daemon.c | less
>> if you want to have look for yourself. It's a single C file.
>> To me handling pid files correctly is the biggest win. The paradigm
>> used commonly in arch
>> PID=`pidof -o %PPID /usr/bin/executable`
>> [ -z "$PID" ] &&  /usr/bin/executable
>> is flawed and does not work reliably as shown here
>> https://bugs.archlinux.org/task/17138
>> I propose to switch to start-stop-daemon and deprecate the method above.
>> http://clemens.endorphin.org/sshd-start-stop-daemon.diff is an example
>> of an rc.d script ported to start-stop-daemon. The paradigm -- to my
>> personal taste -- is clean and simple. The diffstat is negative
>> LOC-wise.
>> We could either take the aur/start-stop-daemon packaging which
>> references dpkg.tar.gz or include into another core package.
>> start-stop-daemon.c is public domain.

In principle I'm in favor of unifying the handling of these sort of
operations, and I agree with Thomas that it should be done in
initscripts as we already have some helper functions there. I'm not
entirely convinced what the best way to do it is, so I'll just make a
few comments:

I think my preferred approach would be to provide some more
helperfunctions in /etc/rc.d/functions which do the most common
operations of the ones you outlined above. Just by glancing over your
ssh-patch I got the impression that we would be better off supporting
fewer options than start-stop-daemon does, to encourage unified/simple
rc scripts. Take --start as an example, we should probably have a
function that looks something like "start($pidfile,$executable,$args)"
. How we implement these functions would be an internal detail of
initscripts (we could either include start-stop-daemon.c or we could
implement them in bash if it is simple enough).

I think we should discuss each function on a case-by-case basis,
whether or not we want to include it.

Several people mentioned systemd: Yes, it is awesome, and it solves
this problem in a much better way than what we can do. However, it is
not relevant to this discussion, as we should aim to have the best rc
scripts possible, regardless of what happens to systemd.

If someone wants to make any suggestions in terms of patches, they are
very welcome at <arch-projects at archlinux.org>.



More information about the arch-dev-public mailing list