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

Hi,

I am executing perl, the statement open(TH, "|$test >$tmpfn" ) works fine but when the close is called on TH (close(TH)) $? returns 15360.

From the code it looks like it expects 256. Is there a document which defines what these return codes mean. Based on some searching...it looks like 15360 is something to do with problem closing the filehandle for piped open... if so what need to be done to overcome this. thanks for your help in advance

P

Replies are listed 'Best First'.
Re: Error code 15360 on close filehandle
by ikegami (Patriarch) on Nov 28, 2011 at 18:19 UTC

    See system for how the error code of programs is arranged.

    Your program used exit(60);. Lots of programs exit with the errno of the error as the exit code. On one of my systems, errno 60 is "Device not a stream".

    $ perl -E'say $!=60' Device not a stream

    Update: Added examination of error code.

      Hello ikegami,

      Thanks for the reply.. I am new to perl...so need some clarification...so do you mean to say that the "$test" program in "open(TH, "|$test >$tmpfn" )" is returning the error code? and it is not a standard error code due to some problem with call that it is failing.

      In the documentation it is written that when using piped open, the open might suceeded..but that does not mean that the command in the open succeeded, it only means the fork succeeded, so I also verified using ps -ef and the command is getting executed.

      Due to this the outfile $tmpfn is also empty

      thanks

        so do you mean to say that the "$test" program in "open(TH, "|$test >$tmpfn" )" is returning the error code?

        The error comes from the child via the waitpid done by close.

        It could from an error that occurred while trying to launch a shell to execute that command produced by "$test >$tmpfn". (Hopefully this isn't possible on your system.)

        Otherwise, it's the error code of the launched shell. The shell will use something based on the error code of the last program it launched as its exit code.

        and it is not a standard error code due to some problem with call that it is failing.

        There is no standard for exit codes except for zero: success, non-zero: error. That's why the meaning of 60 is a guess.