in reply to Re: open3 and illegal seeks
in thread open3 and illegal seeks

ikegami,

I only had the tell statements in there because I was trying to debug the illegal seek message and that was one of the straws that I grasped.

Removing the tell statements and re-running the program still results in the illegal seek error:
Error reading data from STDERR: Illegal seek at test_servicing_request +.pl line 74.
Or did I miss the crux of your message?

Also, how does that explain why my simple sample works but my real CGI script does not? Wouldn't the tell introduce the error in both instances?

Replies are listed 'Best First'.
Re^3: open3 and illegal seeks
by ikegami (Patriarch) on Jul 07, 2009 at 18:20 UTC
    Did you also change your code to look like the following:
    my $error = join('', <$PROG_STDERR>); my $err = $!; die "Error reading data from STDERR: $err" if !eof($PROG_STDERR);

    If you didn't, you haven't shown than an error even occurred.

    Before I do anything else, I'm going to worry about making sure an error actually occurred and about getting the right error message when one does occur.

      The other changes you suggested do prevent the error from happening. If the illegal seek error isn't coming from the read then where is it coming from? What's setting $!?

      I do see how the "or die" on the join could be a logic error on my part because it's going to be the value of the assignment that's checked, which if there's nothing in STDERR, would be empty, which would trigger the "or" condition.

      Something still doesn't add up in my mind though.

        The other changes you suggested do prevent the error from happening.

        No, it means an error never occurred in the first place.

        What's setting $!?

        Some earlier call or some internal call. You could use command line utility strace if you think it's relevant.

        I do see how the "or die" on the join could be a logic error

        Two problems:

        • Your use of $! in the error message when it's not warranted.

        • It does a bad job of detecting an error when one occurs. An error could occur and you wouldn't even know it. (False negative)

        If you *also* want to make sure you received more than zero characters, that's fine. Add that check.