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";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.