Qmail
[Top] [All Lists]

Re: supervise/svc with forked daemon?

To: qmail@list.cr.yp.to
Subject: Re: supervise/svc with forked daemon?
From: Kyle Wheeler <kyle-qmail@memoryhole.net>
Date: Wed, 21 Feb 2007 01:45:28 -0700
Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
Delivered-to: sp-com-lists@consult.net
Delivered-to: gmail-qmail@securepoint.com
Delivered-to: sp.com.list@gmail.com
Delivered-to: mailing list qmail@list.cr.yp.to
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=memoryhole.net; b=bWHyyFK82HnsOXCv0KN8ygfly7ZSuvPSMJFagldrdsHRFaQ/k4x6QWGKnRjCFHlHthpws//YQNrXVnRT4djJgogLfVOoWT3ONhmPGfW8FYK+LBww+gTdd/xt7UhaWWhRgzFiqCOszmAo3CtiTMEQZFY17aoKInwrlol3F27Lnc4= ;
Domainkey-status: good
In-reply-to: <20070221064027.26508.qmail@rahul.net>
Mail-followup-to: qmail@list.cr.yp.to
Mailing-list: contact qmail-help@list.cr.yp.to; run by ezmlm
References: <20070221064027.26508.qmail@rahul.net>
User-agent: Mutt/1.5.13 (2007-02-12)
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

Attachment: pgpPrinIIUFI0.pgp
Description: PGP signature

<Prev in Thread] Current Thread [Next in Thread>