http://qs1969.pair.com?node_id=391370

SmilingBuddha has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks:

I am executing a shell script (on unix) using pipe so to have access to STDOUT and STDERR in filehandle $jobfh:

$jobfh->open("script.sh 2>&1 |");
This script may internally spawn many child processes. If I want to terminate all processes $jobfh->close does not work if the current process (launched by script.sh) is waiting for STDIN.

Thus, I need to kill the above process and all child (how do I create a list of all PIDs of script.sh?) processes of the above when I meet certain conditions in $jobfh. Can you please suggest how I can achieve killing the script (and all its child processes) when launching through open().


Thanks and best Regards.
SmilingBuddha

edit (broquaint): added formatting