in reply to Re: Perl won't Open() when called from Java
in thread Perl won't Open() when called from Java

I was able to fix this but can't understand why. I replaced:

my $syslog_file = "tail -n 0 -f /var/log/messages | "; print STDOUT "some debug line: $syslog_file\n"; open(FH,"syslog_file") print STDOUT "didn't reach before\n";

with:

my $syslog_file = "tail -n 0 -f /var/log/messages | "; print STDERR "some debug line: $syslog_file\n"; open(FH,"syslog_file") print STDERR "reaches now\n";

Why would changing to STDERR make a difference?

Replies are listed 'Best First'.
Re^3: Perl won't Open() when called from Java
by Anonymous Monk on Feb 23, 2012 at 19:35 UTC
    Oh I see. STDERR is unbuffered, but STDOUT buffers. Thanks!
      Yes, that's right. A typical value for the buffer would be 4K. Mileage varies of course! But it it is completely conceivable that since the program is "hung" that there are unprinted things in the buffer.
        It was a hardcoded 4K until recently (5.14?). IIRC, now it's configurable at build time, with a default of 8K