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

发布于 2024-09-28 11:17:07 字数 273 浏览 5 评论 0 原文

我在几个 3 的用法rel="noreferrer">Python 脚本 重新启动进程。据我所知,该约定仅涉及 Unix/Linux 上的 0 和“not 0”。

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

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

Is there a convention defining other values like 3.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

緦唸λ蓇 2024-10-05 11:17:07

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

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.

残疾 2024-10-05 11:17:07

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

即,在这种情况下,只要终止的原因是代码更改而没有其他原因,就会给出自动重新启动的行为。

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.

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.

月野兔 2024-10-05 11:17:07

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

高级 Bash 脚本指南列出了一些具有特殊含义的常见退出代码。

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

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

月棠 2024-10-05 11:17:07

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

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

sysexits3

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文