in reply to Re^4: waitpid stalling on one particular file
in thread waitpid stalling on one particular file

but which is recommended?

Well, it depends...

IPC::Open3 is an old module with an ugly interface and limited functionality. On the other hand you can rely on it being available mostly everywhere as it is distributed with Perl.

IPC::Run is a feature rich module and quite popular too. I find its API too complex, but that is probably the prize you pay for being feature rich!.

There is another alternative if you don't need your scripts to run on any OS other than Linux or Unix: to use the raw POSIX calls (fork, exec, dup2, etc.). In other words, doing it a-la 'C'.

In your particular case, where you are not sending any data to the child process, there is an even simpler solution: to use a single pipe. Perl provides native support for that via the open built-in:

my $pid = open my $rdr, "$cmd |" or die "unable to run external comman +d: $!"; while (<$rdr>) { ... } close $rdr or die "reading from $rdr failed: $!";

Or even better, in order to avoid the shell (specially if it is the today infamous bash!), using the multi-argument open invocation:

my $pid = open my $rdr, '-|', $cmd, @args or die "unable to run extern +al command: $!"; while (<$rdr>) { ... } close $rdr or die "reading from $rdr failed: $!";