exit.c

来自「Newlib 嵌入式 C库 标准实现代码」· C语言 代码 · 共 67 行

C
67
字号
/* * Copyright (c) 1990 Regents of the University of California. * All rights reserved. * * %sccs.include.redist.c% *//*FUNCTION<<exit>>---end program executionINDEX	exitANSI_SYNOPSIS	#include <stdlib.h>	void exit(int <[code]>);TRAD_SYNOPSIS	#include <stdlib.h>	void exit(<[code]>)	int <[code]>;DESCRIPTIONUse <<exit>> to return control from a program to the host operatingenvironment.  Use the argument <[code]> to pass an exit status to theoperating environment: two particular values, <<EXIT_SUCCESS>> and<<EXIT_FAILURE>>, are defined in `<<stdlib.h>>' to indicate success orfailure in a portable fashion.<<exit>> does two kinds of cleanup before ending execution of yourprogram.  First, it calls all application-defined cleanup functionsyou have enrolled with <<atexit>>.  Second, files and streams arecleaned up: any pending output is delivered to the host system, eachopen file or stream is closed, and files created by <<tmpfile>> aredeleted.RETURNS<<exit>> does not return to its caller.PORTABILITYANSI C requires <<exit>>, and specifies that <<EXIT_SUCCESS>> and<<EXIT_FAILURE>> must be defined.Supporting OS subroutines required: <<_exit>>.*/#include <stdlib.h>#include <unistd.h>	/* for _exit() declaration */#include <reent.h>#include "atexit.h"/* * Exit, flushing stdio buffers if necessary. */void _DEFUN (exit, (code),	int code){  __call_exitprocs (code, NULL);  if (_GLOBAL_REENT->__cleanup)    (*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT);  _exit (code);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?