What does the perl interpreter status code mean?

I am trying to execute a copy of the Perl interpreter using Java Runtime.exec (). However, he returned error code 9 . After running the file several times, the perl interpreter mysteriously started returning 253 code without any changes to my command.

What does code 253 / code 9 mean? A google search for perl interpreter exit codes found nothing. Where can I find a list of exit codes for the Perl interpreter?

+4
source share
5 answers

See perldoc perlrun :

If the program is syntactically correct, it is executed. If the program ends without using the exit() or die() operator, an implicit exit(0) provided to confirm successful completion.

Thus, the program you are running must somehow indicate these exit values ​​through die , exit, or the equivalent.

+7
source

Under normal conditions, perl will return everything that the program launches. Therefore, you cannot generalize the value of the return value without knowing that the program is running.

+4
source

Perl itself does not have specific exit codes; if the perl interpreter does not work really badly, the exit code is determined by the program executed by perl , not perl itself.

+4
source

The Perl interpreter actually returns exit codes if the script does not run. Most syntax errors result in code 9 output:

Unknown function / forbidden word:

 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

the unknown module was the only situation in which I found perl to exit in a different way:

 perl -e 'use strict; use doof; print scalar(localtime);' 

$? = 2

BTW I'm still looking for a complete list of perl interpreter exit codes. Has anyone got an idea of ​​where to look besides the sources of the perl interpreter?

+3
source

Since the error code has changed after some runs; if you are using a Java application as a constantly running webapp, check if it could be some kind of memory leak.

You can test your perl script from various problems by running it using the perl -Tw interpreter -Tw , for disabled modes and warnings, see perlrun to learn more about them.

+1
source

Source: https://habr.com/ru/post/1303931/


All Articles