As has already been mentioned, select doesn't work with pipes on
Windows. So this note is just for the record.
$w1 = open(fw1,"pgm1|");
...
$read_set->add($w1);
open() in this case (iff a pipe is involved) returns a PID, whereas IO::Select's add() method is
expecting a file handle... In other words, you'd rather do something like this (on Unix):
my $pid1 = open my $fh1, "pgm1|";
my $pid2 = open my $fh2, "pgm2|";
my $read_set = new IO::Select();
$read_set->add($fh1);
$read_set->add($fh2);
...
BTW, as said, the return value of open() here
is the PID of the subprocess, or undef if the fork failed.
It says nothing about whether the command itself (i.e. pgm1 etc.)
succeeded. For this reason, you'd normally also want to check the return value
when closing the file handle:
close $fh1 or warn "subprocess failed: status=$?\n";
|