Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get the PID of the process I start with Perl's system()?
    text
    copied!<p>I'm writing a Perl script that runs 4 simultaneous, identical processes with different input parameters (see background <a href="https://stackoverflow.com/questions/1961682/using-perl-with-multiple-cores"> here</a> - the rest of my question will make much more sense after reading that).</p> <p>I am making a system() call to a program that generates data (XFOIL, again see above link). My single-core version of this program looks like this:</p> <pre><code>eval{ local $SIG{ALRM} = sub{die "TIMEOUT"}; alarm 250; system("xfoil &lt;command_list &gt;xfoil_output"); alarm 0; }; if ($@){ # read the output log and run timeout stuff... system('killall xfoil') # Kill the hung XFOIL. now it's a zombie. } </code></pre> <p>Essentially, XFOIL should take only about 100 seconds to run - so after 250 seconds the program is hanging (presumably waiting for user input that it's never going to get).</p> <p>The problem now is, if I do a killall in the multi-core version of my program, I'm going to kill 3 other instances of XFOIL, and those processes are generating data. So I need to kill only the hung instance, and this requires getting a PID. </p> <p>I don't know very much about forks and such. From what I can tell so far, I would run an exec('xfoil') inside the child process that I fork. But the PID of the exec() will be different than the PID of the child process (or is it? It's a separate process so I'd assume it is, but again I've no experience with this..), so this still doesn't help when I want to forcefully kill the process since I won't have the PID anyway. How do I go about doing this?</p> <p>Thanks a ton for your help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload