On Tuesday, February 20 at 10:40 PM, quoth John Conover:
Is there any way to use supervise/svc with a daemon that must be
forked into the background, (like arpwatch-the -d option prevents
forking, but disables email notification.)
From the Daemontools FAQ
(http://cr.yp.to/daemontools/faq/create.html):
Q. How can I supervise a daemon that puts itself into the background?
When I run inetd, my shell script exits immediately, so supervise
keeps trying to restart it.
A. The best answer is to fix the daemon. Having every daemon put
itself into the background is bad software design
fghack (http://cr.yp.to/daemontools/fghack.html) can force some
daemons to run in the foreground:
#!/bin/sh
echo starting
exec fghack inetd
Beware that supervise cannot send signals to daemons under fghack.
fghack creates a pipe from the daemon and reads data until the pipe
is closed. Normally all the daemon's descendants will inherit the
open pipe from the daemon, so the pipe will not be closed until
they all exit.
However, fghack will exit early if the daemon goes out of its way
to close extra descriptors. A few of these daemons leave descriptor
0 open, even though they do not use descriptor 0; so
#!/bin/sh
exec fghack baddaemon <&-
might work.
~Kyle
--
Science is what we can tell a computer. Art is everything else.
-- Knuth
pgpPrinIIUFI0.pgp
Description: PGP signature
|