LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Perl script dieing while waiting on select() for some response from another exe (http://www.linuxquestions.org/questions/programming-9/perl-script-dieing-while-waiting-on-select-for-some-response-from-another-exe-801709/)

rajeshkdugar 04-13-2010 04:27 AM

Perl script dieing while waiting on select() for some response from another exe
 
Hi,

I am writing a perl script where forking a child and the child is waiting for some response from C++ exe. Here is the code snippet:

Code:

my $retPid = fork;
if ($retPid)
{
  # I am parent
  ...
  # Install signal handler
  $SIG{CHLD} = \&REAPER;
  ...
  # sleep for a week (6 hours at a time)
  for ($cnt = 0; $cnt < 28 ; $cnt++)
  {
    select(undef, undef, undef, 21600);

    last if ( ! -e "/proc/$retPid" );
  }
  ...
}
else
{
  # I am child
  ($iid, $rc, %data) = $cpp_exe->getResponse(604800);  # 1 week timeout
  ...
}

If the cpp_exe takes very long time (around 30 hours) to respond then the perl script (both parent and child) is dieing. The SIG{CHLD} handler defined in parent is not getting called. It seems parent is dieing first then child is dieing (or may be both dieing at the same time).

Any thoughts why the script is dieing?

Thanks in advance.
--Rajesh

rajeshkdugar 04-22-2010 02:56 AM

The perl script is called from a cgi script. So the owner of the perl processes is apache. Is there any chance that apache is sending some signal to its child processes and that is causing the perl script to die.

Does Apache send SIGHUP while managing its process groups? Can there be any relation between the Apache managing its process groups and Perl script dieing?


All times are GMT -5. The time now is 09:42 AM.