modperl2, fork, and signals
[prev]
[thread]
[next]
[Date index for 2004/11/24]
Hello, i'm working with a kind-of-daemon for my mp2 modules. I will u se =
on Linux but i'm doing the "testing" on a windows machine, and i am =
having troubles with fork processes and signal caching:
Procedure A is auto-forked and live in an infinite-loop.
Procedure B is a function (called by pointing to an URL) to stop this =
infinite loop.
procedure A
--------------------
...
my $stop =3D 1;
$SIG{INT} =3D $SIG{SIGKILL} =3D sub
{
$stop =3D 0;
unlink $dir->{usersD}.'daemon.id';
};
while ($stop)
{
sleep 1;
...
}
--------------------
procedure B
--------------------
my $count =3D 0;
my $server;
while (-e $fileNamePID)
{
$server =3D $obj->get($fileNamePID));
#get the file content, string reference
kill('INT',$$server);
#kill('SIGKILL',$$server);
$count++;
last if $count > 40;
}
--------------------
The problem is that sometimes the signal is received and the process =
finishes (but usually apache crashes), and sometimes (most of times) the =
signal is ignored.
I've realized that without the "sleep" instruction in the while loop the =
signal is always catched and the process finishes always, but sometimes =
apache crashes equally.
Procedure A is a forked process and the PID saved is a negative number.
my $child =3D fork();
return 'bye' if ($child);
(I know that under windows fork is an emulated procedure)
Questions i have:
- Why apache is crashing?
- Is the daemon ignoring the signals when it is sleeping?
- How modperl manage with forked procedures?
Thanks: Apache/2.0.48 (Win32) mod_perl/1.99_13-dev Perl/v5.8.2
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html
 |
modperl2, fork, and signals
=?iso-8859-1?Q?SUCH_SANMART=CDN=2C_GERARD?= 07:28 on 24 Nov 2004
|