简体   繁体   English

perl解释器的状态代码是什么意思?

[英]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(). 我正在尝试使用Java的Runtime.exec()执行Perl解释器的副本。 However, it returned error code 9 . 但是,它返回错误代码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. 在运行该文件几次之后, perl解释器神秘地开始返回代码253,而我的命令完全没有变化。

What does code 253 / code 9 mean? 代码253 /代码9是什么意思? A Google search for perl interpreter's exit codes turned up nothing. Google搜索perl解释器的退出代码没有任何结果。 Where can I find a list of exit codes for the Perl interpreter? 在哪里可以找到Perl解释器的退出代码列表?

See perldoc perlrun : perldoc perlrun

If the program is syntactically correct, it is executed. 如果程序在语法上是正确的,则执行它。 If the program runs off the end without hitting an exit() or die() operator, an implicit exit(0) is provided to indicate successful completion. 如果程序在没有命中exit()die()运算符的情况下运行,则提供隐式exit(0)以指示成功完成。

Thus, the program you are running must be somehow specifying those exit values via die , exit or equivalent. 因此,您运行的程序必须以某种方式通过dieexit或等效指定这些退出值。

In normal circumstances, perl will return whatever the program it runs returns. 在正常情况下, perl将返回它运行的程序返回的任何内容。 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; Perl本身没有任何已定义的退出代码; 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. 除非perl解释器以一种非常可怕的方式崩溃,否则退出代码由perl运行的程序决定,而不是由perl本身决定。

The perl interpreter actually does return exit codes of its own if the script doesn't run. 如果脚本没有运行,perl解释器实际上返回它自己的退出代码。 Most syntax errors lead to exit code 9: 大多数语法错误导致退出代码9:

Unknown function / disallowed bareword: 未知功能/不允许使用裸字:

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

$? $? = 9 = 9

division by zero: 被零除:

perl -e 'use strict; print scalar(localtime); my $s = 1/0;'

$? $? = 9 = 9

syntax error: 语法错误:

perl -e 'use strict; print scalar(localtime); my $ff; $ff(5;'

$? $? = 9 = 9

using die: 使用模具:

perl -e 'use strict; print scalar(localtime); die "twaeng!"'

$? $? = 9 = 9

an unknown module was the only one situation I found perl to exit differently: 一个未知模块是我发现perl以不同方式退出的唯一情况:

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

$? $? = 2 = 2

BTW I'm still searching for a comprehensive list of the perl interpreter's exit codes myself. 顺便说一下,我自己还在寻找perl解释器退出代码的完整列表。 Anyone got an idea where to look, aside from the perl interpreters sources? 除了perl解释器来源之外,任何人都知道在哪里看?

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. 如果您将Java应用程序作为持续运行的Web应用程序运行,请检查它是否可能是某种内存泄漏。

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. 您可以通过使用perl解释器的-Tw选项运行它来测试perl脚本的各种问题,对于已启用的污染模式和警告,请参阅perlrun以获取有关这些的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM