trapping signals in Apache::Test script to reap forks

trapping signals in Apache::Test script to reap forks

am 19.12.2008 23:14:00 von Mark Hedges

Hi. I'm using Apache::Test to develop tests for my OpenID
in-line session-based auth for the upcoming production
release of Apache2::Controller.

In order to do this I have to run a Net::OpenID::Server via
an HTTP::Server::Simple which forks the test script and runs
the test OpenID server into the background.

Trouble is, if I encounter some kind of error in the test
libraries themselves, like use of an uninitialized value
under warnings FATAL => all, or if hit ctl-c while running
the test, the forked child doesn't die, but remains in the
background consuming memory and the temporary port that was
assigned.

I thought maybe I could use sigtrap in the test script and
kill the pid of the child HTTP::Server::Simple. But it
doesn't seem to work. Is this because t/TEST doesn't pass
the signal on to the interpreter of the individual script?

Any idea how I could do this so the forked child of the
openid.t script will always exit cleanly on an error
condition?

Thanks.

Mark

Re: trapping signals in Apache::Test script to reap forks

am 21.12.2008 01:00:55 von Mark Hedges

On Fri, 19 Dec 2008, Mark Hedges wrote:
> In order to do this I have to run a Net::OpenID::Server via
> an HTTP::Server::Simple which forks the test script and runs
> the test OpenID server into the background.
> ...
> Any idea how I could do this so the forked child of the
> openid.t script will always exit cleanly on an error
> condition?

Nevermind, I figured this out, instead of sigtrap pragma I
have to use fully qualified references to
%HTTP::Server::Simple::SIG and exit on INT and I also set an
alarm to exit in case something didn't work.

Mark