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

Oh wise ones,

I have been using the open2 function for a while now, basically I use it to run a process which logs
approximately 32 serial ports and logs the output into 32 seperate files.
Now I have been made aware that there is a lot of information missing from those logs. I have ran several tests
and it looks like that the only 'corrupt logs'->ones missing the info, are only occuring if I run the logging process
using the open2 function.

If I run the logging process by itself(not using my perl script), logs are just fine.

Is anyone aware of similar problems?

Or am I looking in the wrong place?

Any help would be greatly appreciated!

JR

Replies are listed 'Best First'.
Re: open2 question seeking answers
by Zaxo (Archbishop) on Nov 26, 2004 at 05:28 UTC

    Customarily, logging is done over either dedicated handles, or else a redirected STDERR. IPC::Open2::open2() only redirects STDIN and STDOUT. You probably want IPC::Open3 to log over the error channel.

    That is pure guesswork. If you show your code we can be more precise about helping you.

    After Compline,
    Zaxo

Re: open2 question seeking answers
by pelagic (Priest) on Nov 26, 2004 at 08:45 UTC
    As has been said before: check to what filehandle logs are written to. Probably some stuff is written to STDERR which is not catched by open2. Best thing might be to use open3 instead.
    And here comes my warning:
    open 2 and open3 have different order of the filehandles.
    my $pid = open3(\*WTRFH, \*RDRFH, \*ERRFH, $command, @args) or die"Error executing <$command>, Couldn't fork: <$!>."; ## vs. my $pid = open2(\*RDRFH, \*WTRFH, $command, @args) or die"Error executing <$command>, Couldn't fork: <$!>.";
    Share and enjoy!

    pelagic