LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-13-2010, 04:27 AM   #1
rajeshkdugar
LQ Newbie
 
Registered: Apr 2010
Distribution: CentOS
Posts: 7

Rep: Reputation: 0
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
 
Old 04-22-2010, 02:56 AM   #2
rajeshkdugar
LQ Newbie
 
Registered: Apr 2010
Distribution: CentOS
Posts: 7

Original Poster
Rep: Reputation: 0
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?
 
  


Reply

Tags
perl, scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dhcpcd timing out waiting for server response theofb Linux - Newbie 2 09-15-2008 08:43 AM
Perl Script to select common lines in two files. perluser59 Programming 12 05-26-2008 02:19 AM
how to use perl.exe in shell script littletransformer Programming 7 12-03-2007 03:14 AM
Perl script/mysql select query from a file mcdrr Programming 12 06-05-2007 12:00 AM
tor - waiting for response noir911 *BSD 1 06-29-2006 06:33 AM


All times are GMT -5. The time now is 10:26 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration