c - 为什么 exit() 函数在 C "never fail"中?

标签 c exit

我正在阅读 Head First C,它说“exit() 是唯一保证永远不会返回值并且永远不会失败的函数。”

  1. C 中是否还有其他函数不应返回任何可能返回的内容?

  2. 为什么会这样exit()永远不会失败?

最佳答案

Are there other functions in C that are supposed to not return anything that might?

有点。 exec() 系列(execlexeclpexecve 等)将用新的进程替换当前进程。成功时可执行 - 因此,成功时永远不会返回 - 或如果失败则返回 -1(并设置 errno )。

Why is it that exit() never ever fails?

怎么会失败呢?没有任何东西可以阻止进程退出。

关于c - 为什么 exit() 函数在 C "never fail"中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46107011/

相关文章:

c - 无限循环的退出

c - #define 在 GCC 中的内联汇编

c - 函数作为变量使用,如何使用其内存地址知道实际调用了哪个函数

c - 无需在 C 中使用 goto 即可优雅地退出函数的优雅方式

bash - 在 bash 中使用 "exit ${?}"是否正确?

python - 即使我包含了库,python 也会出错

jquery - 使用 HTML5 视频标签退出全屏

c++ - 为什么未初始化的 const 成员在 C 中的处理方式与在 C++ 中的处理方式不同?

c++ - C 等同于 C++ get_temporary_buffer?

c - 在 C 中获取子字符串