查找出codeS的Linux的命令行工具的含义是什么意思
问题说明
我有我的提示符(bash)的配置为从最后的命令打印出的退出code,如果没有成功(又名不为零)。因此,我看到了很多的退出codeS的,即使程序似乎不会遇到问题。 有没有办法来查找这些退出$ C $的含义CS?
I have my prompt (bash) configured to print out the exit code from the last command, if it wasn't successful (aka not zero). Therefore I'm seeing a lot of exit codes, even when a program seems to encounter no problems. Is there a way to lookup the meaning of these exit codes?
我总是试图手册页,信息页或--help选项,但无济于事。
I always try the man pages, info pages or the "--help" option, but to no avail.
要澄清,我问来与Linux的公用事业,如 CD
, LS
,杜
...
To clarify, I'm asking about the utilities that come with Linux, like cd
, ls
, du
, ...
正确答案
有没有为退出$ C $的超越'0就OK节目CS的标准化含义;别的意思出事了。严格,适用于C和C 只 - 在那里,退出(0);
或退出(EXIT_SUCCESS);
出口都成功,但回到O / S的值可能会有所不同。
There isn't a standardized meaning for the exit codes of programs beyond '0 is OK; anything else means something went wrong'. And strictly, that applies to C and C only - there, exit(0);
or exit(EXIT_SUCCESS);
both exit with success, but the value returned to the O/S might be different.
有例外,即使是零上的成功规则。很显然,有不返回定义的退出状态粗心的方案;这样的程序最好避免。有迹象表明,始终返回0,即使出事了其他没有这么粗心方案;他们也往往是最好避免。
There are exceptions to even the zero-on-success rule. Obviously, there are careless programs that don't return a defined exit status; such programs are best avoided. There are other not quite so careless programs that always return 0, even when something went wrong; they too are often best avoided.
不过,也有细心的连接code相当多的信息进入退出状态,而仅仅让一个非零退出状态并不意味着这种方案失败的方案。当然,程序文件的退出状态的含义。
However, there are also programs that carefully encode quite a lot of information into the exit status, and simply getting a non-zero exit status does not mean such programs failed. Of course, the programs document the meanings of the exit statuses.
POSIX是仔细记录退出状态的项目。
POSIX is careful to document exit statuses for programs.
有关程序应当记录出口状态的手册页。在Unix上,如果没有这些文件,那么假设零上的成功和别的是失败的。
The manual pages for a program should document the exit statuses. On Unix, if there is no such documentation, then assume zero-on-success and anything else is a failure.
请注意,如果庆典
未能执行的命令,它会返回程式化的状态:
Note that if bash
fails to execute a command, it will return stylized statuses:
- 127如果文件不存在或无法找到
- 126,如果你没有对文件的执行权限
此外,如果程序死掉,因为一个信号,庆典
让你知道通过编码作为退出状态:
Also, if the program dies because of a signal, bash
lets you know by encoding the exit status as:
128 信号数
128 signal-number
因此SIGHUP产生129,SIGILL产生132,SIGTERM产生143等。但是,它有可能为一个程序,在使用这些状态的退出,意味着什么东西从庆典表示。这就是说,它是一个比较特殊的程序,在使用这些退出状态的退出,所以你通常是安全的。
Hence SIGHUP yields 129, SIGILL yields 132, SIGTERM yields 143, etc. However, it is possible for a program to exit with any of those statuses and mean something different from what bash
means. That said, it is a relatively unusual program that exits with any of those exit statuses, so you're usually safe.
请注意,不同的操作系统有不同的约定:UNIX提供零取得成功的8位状态;窗口提供退出状态值(16位或32位)大得多的范围; VMS采用零就意味着失败,我相信。
Note that different operating systems have different conventions: Unix provides an 8-bit status with zero for success; Windows provides a much larger range for the exit status values (16-bits or 32-bits); VMS used zero to mean failure, I believe.
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcfkegj
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20