[PLUG] perl Open3 : does not write errors in the file provided.
bharatlohiya at gmail.com
Thu Oct 4 09:29:55 PDT 2007
I have a problem while writing a program in perl.
I am creating a process using Open3. Here goes the code.
use Symbol qw(gensym);
print STDOUT "$ERR_LOGS\n";
open( $ER,">>$ERR_LOGS") || die "Unable to open error file $ERR_LOGS $!\n";
my $pid=open3($WR,$RD,$ER,$process) || die "$!\n"; <==== problem
........(firing commands by writing on $WR and reading output from $RD, but
it should write the errors on $ERR_LOGS, as $ER is associated with it)
This is a small part of code I have written, the problem I am facing here is
that the function open3 is not writing the errors on the $ERR_LOGS file. But
while execution I can see " /proc/<pid>/fd/4", has the errors of the
With this code, it gets stuck somewhere in the program execution, because of
not getting fd/4 flushed(in my opinion). To overcome that I tried replacing
$ER in Open3 statement with "STDERR" which subsequently flushes all errors
(and does not get stuck anywhere and run the whole process till the end
successfully, but no logging of errors), and hence I can not see any error
file descriptor associated with the process in /proc.
Since I want to capture the errors according to the requirement of the
project, I tried various other methods but nothing is running the full
program and capturing the process errors.
The other methods I tried are.
1. open the ERR_LOGS file with another $PROC_ERR and passed this with open3
instead of $ER. => got stuck and did not log the error in file.
2. open the error file with $PROC_ERR and passed $ER with open3, and reading
from $ER as I read $RD with the help of "sysread function". But it get stuck
when it first encounters reading $ER.
Kindly help. If any information is required kindly let me know Ill try to
More information about the plug-mail