So I tried to print out pid in parent process. It turned out to be 22718.
However I did "top" right after I launched the script. The ID of main process is 22717 while that of kid process is 22719. As a result the kid process is not killed. Why is that?
My code looks like this:
if ($pid=fork)
{
print $pid, "\n";
do{
if (-e "mdinfo")
{
$last=`tail -1 mdinfo`;
if ($last =~ /Density/)
{
@last_mdinfo=split ' ',$last;
$den=$last_mdinfo[2];
}
}
} while ($den < 1.0000 or $den > 1.005);
kill 15, $pid;
}
elsif (defined($pid))
{
exec(qq(/opt/amber/bin/sander -i ele1.0.mdin -c ele1.0.inpcrd -p e
+le1.0.prmtop -o ele1.0.mdout -r ele1.0.restrt &));
exit(0);
}
else {
print "child was not created\n";
}
print "done\n";
|