What does the status code of the perl interpreter mean?
I'm trying to execute a copy of the Perl interpreter using Java's Runtime.exec(). However, it returned error code 9
. After running the file a few times, the perl
interpreter mysteriously started to return code 253 with no changes in my command at all.
What does code 253
/ code 9
mean? A Googl开发者_开发百科e search for perl
interpreter's exit codes turned up nothing. Where can I find a list of exit codes for the Perl interpreter?
See perldoc perlrun:
If the program is syntactically correct, it is executed. If the program runs off the end without hitting an
exit()
ordie()
operator, an implicitexit(0)
is provided to indicate successful completion.
Thus, the program you are running must be somehow specifying those exit values via die, exit or equivalent.
The perl interpreter actually does return exit codes of its own if the script doesn't run. Most syntax errors lead to exit code 9:
Unknown function / disallowed bareword:
perl -e 'use strict; print scalar(localtime); schei;'
$? = 9
division by zero:
perl -e 'use strict; print scalar(localtime); my $s = 1/0;'
$? = 9
syntax error:
perl -e 'use strict; print scalar(localtime); my $ff; $ff(5;'
$? = 9
using die:
perl -e 'use strict; print scalar(localtime); die "twaeng!"'
$? = 9
an unknown module was the only one situation I found perl to exit differently:
perl -e 'use strict; use doof; print scalar(localtime);'
$? = 2
BTW I'm still searching for a comprehensive list of the perl interpreter's exit codes myself. Anyone got an idea where to look, aside from the perl interpreters sources?
In normal circumstances, perl
will return whatever the program it runs returns. Hence you can not generalize the meaning of the return value without knowing the program it's running.
Perl itself doesn't have any defined exit codes; unless the perl interpreter crashes in a really horrific way, the exit code is determined by the program that perl
is running, not by perl
itself.
Since the error code changed after some runs; if you are running a Java
app as a continuously running webapp, check if it can be some kind of memory leak.
You can test your perl
script from various problems by running it with the perl interpreter's -Tw
options, for tainted modes and warnings enabled, see perlrun for more info about these.
精彩评论