perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SUCH SANMART√ćN, GERARD <gs...@imim.es>
Subject modperl2, fork, and signals
Date Wed, 24 Nov 2004 07:28:05 GMT
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 = 1;
$SIG{INT} = $SIG{SIGKILL} = sub
 {
 $stop = 0;
 unlink $dir->{usersD}.'daemon.id';
 };

while ($stop)
 {
 sleep 1;
 ...
 }
--------------------



procedure B
--------------------
my $count = 0;
my $server;
while (-e $fileNamePID)
 {
 $server = $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 = 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


Mime
View raw message