autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: autotest: problem testing daemons, with possible fix


From: Luke Mewburn
Subject: Re: autotest: problem testing daemons, with possible fix
Date: Fri, 26 Nov 2010 10:13:12 +1100
User-agent: Mutt/1.5.20 (2009-06-14)

On Thu, Nov 25, 2010 at 10:36:23PM +0200, Andrew W. Nosenko wrote:
  | On Wed, Nov 24, 2010 at 06:58, Luke Mewburn <address@hidden> wrote:
  | > I've been using autotest for a couple of years, for unit tests
  | > and overall system systems of large daemons, that daemonize
  | > themselves using the daemon(3) function (originally from 4.4BSD,
  | > also in glibc).
  | >
  | > Until now I've been using a workaround for starting the daemon
  | > because "something" was preventing AT_CHECK from determining that
  | > the daemon startup had occurred correctly, so it was hanging in
  | > the check. ?Our workaround was a wrapper program which closes all
  | > file descriptors before starting the daemon.
  | 
  | Excuse me, but why you didn't close all FDs inside your daemon before
  | daemonizing at all?
  | 
  | Properly written daemon shoud to do it anyway for preventing opened
  | FDs to be "leaked" forever (ok, not forever but until the daemon will
  | be shuted down).

As I said, I'm using daemon() which only has an option to close
the standard descriptors (0..2) and reopen them to /dev/null.

Whilst I agree that the best practice for a daemon should be to
close down all descriptors early in the process lifecycle
(before calling daemon()), this is not always feasible in every
application - fds opened by the app before daemon need to stay
open, but others need to be closed - so implementing a variation
of daemon() with a 'close all fds' option wouldn't be sufficient
either.

Prior art in various daemons also shows that most only close
down 0..2 (relying upon daemon() to do this).
Some shells also automagically close fds over 2, which developers
may have relied upon in the past;  see the comments about ksh in
section 11.3 of the autoconf manual.

So, whilst we can argue about what a daemon should or shouldn't do
in the best case, I think my proposal is a simple fix to a problem
that has affected at least one other person (see the message I
linked to in my original post).  If autotest isn't going to be
modified to fix this issue, the documentation for AT_CHECK should
be updated to highlight that the fd used by the message log should be
closed if testing a daemon or other process that is to be background
during AT_CHECK to keep executing past AT_CHECK.


cheers,
Luke.

Attachment: pgpTpeinO9ZvG.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]