Does Android care about exit status code passed to System.exit(…)?

百般思念 提交于 2019-12-22 04:06:09

问题


If I kill an Android app with System.exit(...), does it matter what status code I pass? I couldn't find any documentation on whether Android just ignores it or whether certain ones lead to any error messages for example or have any other meaning.


回答1:


This is the exit code returned by the process when it finishes; Android however does not care, but know that the error code should never be higher then 255.

Here is a list of standard exit codes - some process may use their own codes.

0    Clean Exit
1    General Error Catchall
2    Misuse of shell builtins
126  Command invoked execution error
127  Command not found
128  Invalid exit argument?
130  Termination by Control-C
255  Exit status unknown




回答2:


Android does not care, no. This is a java thing -- you can use them for your own debugging etc etc.

Here's an example of system exit codes: http://www.opensource.apple.com/source/Libc/Libc-320/include/sysexits.h

But pretty much, anything > 0 means that its an abnormal exit. You can set it to whatever you want, but I'd just stick to 0 unless you're interacting with other things.

It just seems to be the accepted convention.



来源:https://stackoverflow.com/questions/30226842/does-android-care-about-exit-status-code-passed-to-system-exit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!