quick_exit

来自cppreference.com
< c‎ | program
在标头 <stdlib.h> 定义
_Noreturn void quick_exit(int exit_code );
(C11 起)
(C23 前)
[[noreturn]]void quick_exit(int exit_code );
(C23 起)

导致程序正常终止,而不完全清理资源。

以注册顺序的逆序调用传递给 at_quick_exit 的函数。调用完注册的函数后,调用 _Exit(exit_code)

目录

[编辑]参数

exit_code - 程序的退出状态

[编辑]返回值

(无)

[编辑]示例

#include <stdlib.h>#include <stdio.h>   void f1(void){puts("pushed first");fflush(stdout);}   void f2(void){puts("pushed second");}   void f3(void){puts("won't be called");}   int main(void){at_quick_exit(f1);at_quick_exit(f2);atexit(f3); quick_exit(0);}

输出:

pushed second pushed first

[编辑]引用

  • C17 标准(ISO/IEC 9899:2018):
  • 7.22.4.7 The quick_exit function (第 257 页)
  • C11 标准(ISO/IEC 9899:2011):
  • 7.22.4.7 The quick_exit function (第 353 页)

[编辑]参阅

引发非正常的程序终止(不清理)
(函数)[编辑]
注册一个要在调用 exit() 时调用的函数
(函数)[编辑]
注册要在调用 quick_exit 时调用的函数
(函数)[编辑]
quick_exit 的 C++ 文档
close