当断言()失败,是什么程序退出code? [英] When assert() fails, what is the program exit code?

查看:272
本文介绍了当断言()失败,是什么程序退出code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当一个 断言() 调用失败,什么是用于出口code和它在哪儿记录?

When an assert() call fails, what is the exit code used, and where is it documented?

推荐答案

C99标准规定,断言通话中止中止的东西这个国家对返回code:

The c99 standard states that assert calls abort and the abort stuff states this about the return code:

状态成功终止的实现定义的形式由函数调用加薪(SIGABRT)的方式返回到主机环境。

An implementation-defined form of the status unsuccessful termination is returned to the host environment by means of the function call raise(SIGABRT).

它记录在C99标准的here

It's documented in section 7.2.1.1 (assert) and 7.20.4.1 (abort) of the c99 standard here.

许多UNIX系统将返回128加上信号编号(SIGABRT信号是6号),所以你可能会得到134不管你得到的,应该由C实现记录在案。

Many UNIX systems will return 128 plus the signal number (SIGABRT is signal number 6) so you may get 134. Whatever you get, it should be documented by the C implementation.

例如,请参见这里 GCC。虽然这是什么获取返回到调用环境相当沉默。从具体章节<一个href=\"http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/C-Implementation.html#C-Implementation\">here:

For example, see here for gcc. Although it's quite silent on what gets returned to the calling environment. From the specific sections here:

有些选择是由图书馆和操作系统(或其他环境编译为一个独立的环境时)作出的;请参阅其文档以了解详情。

Some choices are made by the library and operating system (or other environment when compiling for a freestanding environment); refer to their documentation for details.

和<一个href=\"http://gcc.gnu.org/onlinedocs/gcc-4.5.0/gcc/Library-functions-implementation.html#Library-functions-implementation\">here:

大多数这些点的行为依赖于C库的实现,而不是通过GCC本身定义的。

The behavior of most of these points are dependent on the implementation of the C library, and are not defined by GCC itself.

原来是glibc的DOCO <一个href=\"http://www.gnu.org/s/libc/manual/html_node/Program-Termination.html#Program-Termination\">here在程序终止(具体的退出状态位)。它提到公约,但没有确切的规则。

So is the glibc doco here on program termination (specifically the exit status bit). It mentions conventions but no firm rules.

这篇关于当断言()失败,是什么程序退出code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆