autoconf
[Top][All Lists]
Advanced

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

autotest: problem testing daemons, with possible fix


From: Luke Mewburn
Subject: autotest: problem testing daemons, with possible fix
Date: Wed, 24 Nov 2010 15:58:47 +1100
User-agent: Mutt/1.5.20 (2009-06-14)

Hi folks,

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.

In some spare time recently I decided to debug the problem, because
I'd rather not need to (re)implement the wrapper program for every
application I write.

If I use the attached test program and autotest fragment and
run it, the AT_CHECK "hangs" for 10 seconds (for the sleep(10)),
even though it should exit very quickly as the process
daemonizes itself.

With a bit of poking around with lsof, I confirmed that the
daemon has fd 5 open and having that open in the child appears
to stop the testsuite from detecting that the process is
"finished" (i.e, backgrounded & daemonized).

If I explicitly close fd 5 before running the daemon, it works
as I would expect.  I.e, change
    AT_CHECK([unittest_daemon], [0], [], [])
to
    AT_CHECK([unittest_daemon 5>&-], [0], [], [])

Is there any reason that AT_CHECK doesn't close this fd before
executing the application?
I've attached a patch that performs this, against autoconf-2.68.


I note that this issue previously came up on the autoconf
list in the thread:
    http://lists.gnu.org/archive/html/autoconf/2009-08/msg00002.html
and it didn't seem to me that there was an adequate resolution
at that time.


regards,
Luke.

Attachment: unittest_daemon.c
Description: Text document

Attachment: check-daemon.at
Description: Text document

Attachment: atcheck_fdfix.patch
Description: Text document

Attachment: pgpUJ1CW3aK5T.pgp
Description: PGP signature


reply via email to

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