I have a program that should run a set of other programs and collect their results for logging. Everything works fine as long as the standard version is issued.
This leads me to two of my problems:
How can I capture both STDIN and STDERR another program in one file?
If there is no output (or output only to STDERR ), the program will get stuck in the line:
while (<$input>)
How can I make a program wait for another program to exit with an undefined runtime and continue to work if there is no exit by the time the program ends.
Here is this section of code
my $pid = open (my $input, '-|', "$prog $args") or push @errors, "A failute has occurred in $prog $args"; if(not @errors){ while (<$input>){
note: $fh is my file handler used to write to the log file, and @errors used for internal error messages in my program.
EDIT: One of the problems that I encountered while trying Proc :: Reliable is that it seems to have consequences after STDOUT and STDERR , and I will need to fix them after each run. This leads to another problem in my code. I work in parallel, and any change to STDOUT and STDERR affects all threads (at least on Windows).
IO :: CaptureOutput has the same problem for me, but it tries to fix the STDOUT and STDERR errors internally and causes the following error:
Couldn't remove temp file 'C:\Users\SBLAKE~1\AppData\Local\Temp\m8E3pUGfOS' - Permission denied at C:/Perl/site/lib/IO/CaptureOutput.pm line 82
Shawn blakesley
source share