⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exit.c

📁 用于嵌入式Linux系统的标准C的库函数
💻 C
字号:
/* * 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>#ifndef _REENT_ONLY/* * Exit, flushing stdio buffers if necessary. */void _DEFUN (exit, (code),	int code){  register struct _atexit *p;  register struct _on_exit_args * args;  register int n;  int i;#ifdef _REENT_SMALL  p = &_GLOBAL_REENT->_atexit;  args = p->_on_exit_args_ptr;    if (args == NULL)    {      for (n = p->_ind; n--;)        p->_fns[n] ();    }  else    {      for (n = p->_ind - 1, i = (n >= 0) ? (1 << n) : 0; n >= 0; --n, i >>= 1)        if (args->_fntypes & i)          (*((void (*)(int, void *)) p->_fns[n]))(code, args->_fnargs[n]);        else          p->_fns[n] ();    }#else  p = _GLOBAL_REENT->_atexit;  while (p)    {      args = & p->_on_exit_args;        for (n = p->_ind - 1, i = (n >= 0) ? (1 << n) : 0; n >= 0; --n, i >>= 1)        if (args->_fntypes & i)          (*((void (*)(int, void *)) p->_fns[n]))(code, args->_fnargs[n]);        else          p->_fns[n] ();      p = p->_next;    }#endif  if (_GLOBAL_REENT->__cleanup)    (*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT);  _exit (code);}#endif

⌨️ 快捷键说明

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