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