Linux 进程退出状态 3 是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3996061/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:45:54  来源:igfitidea点击:

What does process exit status 3 mean?

pythonlinuxunixprocessstatus

提问by deamon

I've seen the usage of exit status 3in several python scriptsthat restart processes. As far as I know the convention is only about 0and "not 0" on Unix/Linux.

我已经3在几个重新启动进程的python 脚本中看到了退出状态的使用。据我所知,该约定仅适用于 Unix/Linux,0而不是0“非”。

Is there a convention defining other values like 3.

是否有定义其他值的约定,例如3.

采纳答案by Brandon Rhodes

At least in the old days, a return value of 1 generally meant a hard error and value 2 was usually reserved for problems with the command line arguments — it meant that the user had made an error, not the program. But beyond that: no, no convention; and even that slight convention was not universal. Like dashes in front of command-line arguments, which some versions of ps(1)let you omit, return codes were just convention. In general, read the docs (or the source!) to the script you're running and you then have to write error-code checking code to its specific meanings.

至少在过去,返回值 1 通常意味着硬错误,而值 2 通常保留用于命令行参数的问题——这意味着用户犯了错误,而不是程序。但除此之外:不,没有约定;甚至那个小小的约定也不是普遍的。就像命令行参数前面的破折号一样,某些版本的ps(1)允许您省略,返回代码只是约定。通常,阅读文档(或源代码!)到您正在运行的脚本,然后您必须编写错误代码检查代码以了解其特定含义。

回答by ckk

There is no convention for non-zero values, they are commonly used to communicate the reason for termination and it's up to each application to define the mapping of error code and reason. In the case you're linking to you can clearly see a few lines above the check for exit code 3 that it is used to indicate that the code has changed.

非零值没有约定,它们通常用于传达终止的原因,并且由每个应用程序定义错误代码和原因的映射。在您链接到的情况下,您可以清楚地看到检查退出代码 3 上方的几行,它用于指示代码已更改。

Ie in this case this will give the behaviour that the automatic restart is done as long as the reason to terminate was that the code changed and nothing else.

即,在这种情况下,只要终止的原因是代码更改而不是其他任何原因,就会产生自动重新启动的行为。

回答by JS.

BSD tried to standardize exit codes, but it didn't (hasn't yet?) caught on:

BSD 试图标准化退出代码,但它没有(还没有?)流行起来:

sysexits3

sysexits3

回答by J. Polfer

In this case, its unclear. foret's suggestion is one I would totally do if the developer is still around.

在这种情况下,它不清楚。如果开发人员还在,foret 的建议是我完全会做的。

The Advanced Bash Scripting Guide lists some common exit codes with special meanings.

Advanced Bash Scripting Guide 列出了一些具有特殊含义的常见退出代码。