in reply to Open3 in child process not capturing errors correctly. .

I would guess that rsh is doing something strange. I don't have it here but the code example looks like it should work. Certainly the following snippet works perfectly:
#! /usr/bin/perl use IPC::Open3; use IO::Handle; my $writer = IO::Handle->new(); my $reader = IO::Handle->new(); eval { my $cpid = open3( $writer, $reader, $reader, "perl" ); }; die if $@; print $writer <<'PROG'; print STDOUT "Hello to STDOUT\n"; print STDERR "Hello to STDERR\n"; PROG close($writer); print <$reader> if @ARGV;
I would try the rsh command from the shell, redirecting errors using the standard 2>&1 syntax.

But an important non-stylistic note. After your eval, check $@ and if it is true then make darned sure that you register an error. Also make sure that the error message has all of the information listed in perlstyle. In this case that would include your description of what was going on, the exact rpc command, and the full text of the error. Look for the "open3" pattern to figure out whether you will die or print a message. But make that message actually useful for debugging!!!

Based on past painful experience I will refuse to work with code that doesn't take this basic step. Education is key. And a job where I found myself dealing with this kind of code without being allowed to do something about it (eg rewrite) would be a job I would shortly leave...

  • Comment on RE (tilly) 1: Open3 in child process not capturing errors correctly. .
  • Download Code

Replies are listed 'Best First'.
RE: RE (tilly) 1: Open3 in child process not capturing errors correctly. .
by geektron (Curate) on Oct 26, 2000 at 10:07 UTC
    on the non-stylistic tip: i had the check for $@ in there originally. it was rather sloppy of me to not have it in the posted snippet.

    i'm just stumped, because a similar throw-away script i wrote works fine ( but has globbed filehandles instead of IO::Handle objects ).