java.lang.Process#waitFor() 的退出值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18015491/
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-11 21:48:13  来源:igfitidea点击:

Exit value from java.lang.Process#waitFor()

java

提问by ParagJ

The method waitFor()returns an integer value which is the return code. The value 0 indicates normal termination. But what are the meanings of other return codes? I am getting an exit value 11. What does that mean? And where all the exit value codes are documented?

方法waitFor()返回一个整数值,它是返回码。值 0 表示正常终止。但是其他返回码的含义是什么?我得到一个退出值 11。这是什么意思?所有退出值代码都记录在哪里?

采纳答案by Uku Loskit

These values are arbitrary and up to the specific program to define. You should refer to documentation or source code of the program that is outputting this exit code.

这些值是任意的,由具体的程序来定义。您应该参考输出此退出代码的程序的文档或源代码。

回答by jnovacho

The program return value depends on program. There is no standard for return values apart from zero meaning OK.

程序返回值取决于程序。除了零意味着 OK 之外,没有返回值的标准。

You have to contact author of the program or consult documentation.

您必须联系该程序的作者或查阅文档。

回答by John Smith

Every application defines it's own exit codes. E.g. you have to look up the documentation of the application that you started using java.lang.Process. The only common thing they all have is that any other value than 0 is an error.

每个应用程序都定义了自己的退出代码。例如,您必须查找使用 java.lang.Process 启动的应用程序的文档。它们唯一的共同点是,除 0 以外的任何其他值都是错误。

In the unix world on the other hand there are certain conventions, that many main stream utilities follow, but there are no guarantees.

另一方面,在 unix 世界中有某些约定,许多主流实用程序都遵循这些约定,但没有保证。

回答by Narendra Pathai

Any value other than non-zerovalue indicates Abnormal termination. There is no particular rule as to what values indicate what conditions. Read the documentation for the process that you are calling.

非零值以外的任何值都表示异常终止。什么值表示什么条件没有特别的规则。阅读您正在调用的进程的文档。

0 --> Normal termination

!=0 --> Abnormal Termination

0 --> 正常终止

!=0 --> 异常终止

回答by dghelani

I have seen conversions happen of the nature that can convert intended negative error codes to convert as follows -

我已经看到可以将预期的负错误代码转换为如下转换的性质的转换 -

Error code –> -2001 -> Signed Decimal to Binary conversion -> 111111111111100000101111 -> Here 00101111 last 8 bit is picked up and converted back to Decimal – 47 !!

错误代码 -> -2001 -> 有符号十进制到二进制的转换 -> 111111111111100000101111 -> 这里 00101111 最后 8 位被拾取并转换回十进制 - 47 !