Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

PERL exit code 255

by mcintst (Initiate)
on Oct 04, 2006 at 00:48 UTC ( #576220=perlquestion: print w/ replies, xml ) Need Help??
mcintst has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone tell me what an exit code of 255 means? I'm troubleshooting someone else's PERL script that's set up as a scheduled job and 99% of the time it exits with value 0 but every now and again it exits with 255. This is not being set within the perl script so I presume it is due to some abnormal termination of the code. Can't find this referenced anywhere... -Stuart.

Comment on PERL exit code 255
Re: PERL exit code 255
by jasonk (Parson) on Oct 04, 2006 at 01:16 UTC

    Generally speaking it means that within the program there is a line that says exit(255). Keep in mind that on unix systems exit codes are 8 bits, so if you think that your code isn't throwing that exit code because you grepped all the code for exit(255) and didn't find anything, it may be that you didn't look hard enough...

    [jason@dev]$ perl -e 'exit -1'; [jason@dev]$ echo $? 255

    We're not surrounded, we're in a target-rich environment!
      all of the non null exit statements within the script are preceeded by a write to an error log, and none mention the value 255 (or even -1) I don't see anything written to the error log so I assume that PERL itself is setting that exit code... -Stuart.
      One possibility that I came across is dividing by zero.
Re: PERL exit code 255
by Dietz (Curate) on Oct 04, 2006 at 05:13 UTC

    I assume this is most likely caused by a die statement in your script:

    $ perl -le 'die' Died at -e line 1. $ echo $? 255
Re: PERL exit code 255
by Popcorn Dave (Abbot) on Oct 04, 2006 at 05:47 UTC
    What OS is it under? The error may be an OS error, not a Perl error. That's the place I'd be looking.

    Revolution. Today, 3 O'Clock. Meet behind the monkey bars.
      I tend to agree. There is no 'die' statement in the whole script so I suspect that the OS (Windows 2000 server) tries and fails to run the PERL script and returns the value 255. -Stuart.
        There is no 'die' statement in the whole script

        The thing is that there doesn't have to be a die statement or an explicit exit(255) in the script to get an exit value of 255. But something must be setting that value. As a (somewhat ridiculous) example, if you have a C compiler you could compile the following C program into 'try.exe':
        int main(int argc, char * argv[]) { return 255; }

        And then you could run the following perl script:
        use warnings; my $ret = system("try.exe"); print $ret >> 8, "\n", $? >> 8, "\n";

        You would find that produces as output:
        255 255

        In that perl script, there's no die(), no mention of "255" and, in fact, nothing even failed - yet the 8 high bits of $? were set. (Hopefully, you don't have an executable that's running successfully and returning 255.)

        How do you find out what the exit code is ? Is there a 'print $exitcode;' in the script ? ... or a 'print $? >> 8;' ? ... If we know the means by which you are being made aware of the exit value, then that might help with our speculations.

        Cheers,
        Rob
Re: PERL exit code 255
by Hue-Bond (Priest) on Oct 04, 2006 at 10:55 UTC

    Try with:

    $SIG{$_} = sub { exit 42; } for keys %SIG; END { exit 42; }

    If, with that change, the code keeps on returning 255 sometimes, you know that the cause is not in the code. Don't forget to remove it afterwards!

    --
    David Serrano

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://576220]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2014-11-26 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (173 votes), past polls