Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
EXITS(3)		   Library Functions Manual		      EXITS(3)

       exits,  _exits,	exitcode,  atexit,  atexitdont	-  terminate  process,
       process cleanup

       #include	<u.h>
       #include	<libc.h>

       void _exits(char	*msg)
       void exits(char *msg)

       int  exitcode(char *msg)

       int  atexit(void(*)(void))

       void atexitdont(void(*)(void))

       Exits is	the conventional way to	terminate a process.  _Exits also ter-
       minates	a  process  but	 does  not call	the registered atexit handlers
       (q.v.).	They can never return.

       Msg conventionally includes a brief (maximum length ERRLEN) explanation
       of  the	reason for exiting, or a null pointer or empty string to indi-
       cate normal termination.	 The string is passed to the  parent  process,
       prefixed	 by  the  name and process id of the exiting process, when the
       parent does a

       Before calling _exits with msg as an argument, exits calls  in  reverse
       order all the functions recorded	by atexit.

       Atexit records fn as a function to be called by exits.  It returns zero
       if it failed, nonzero otherwise.	  A  typical  use  is  to  register  a
       cleanup	routine	for an I/O package.  To	simplify programs that fork or
       share memory, exits only	calls those atexit-registered  functions  that
       were registered by the same process as that calling exits.

       Calling	atexit	twice (or more)	with the same function argument	causes
       exits to	invoke the function twice (or more).

       There is	a limit	to the number of exit functions	that will be recorded;
       atexit returns 0	if that	limit has been reached.

       Atexitdont cancels a previous registration of an	exit function.


       Because	of  limitations	of Unix, the exit status of a process can only
       be an 8-bit integer.  Exits and _exits treat null or empty exit	status
       as  exit	code 0 and call	exitcode to translate any other	string into an
       exit code.  By default, the library provides an exitcode	that maps  all
       messages	 to  1.	  Applications may find	it useful to provide their own
       implementations of exitcode .

       Exit codes 97 through 99	are used by the	thread library to  signal  in-
       ternal  synchronization	errors	between	 the  main program and a proxy
       process that implements backgrounding.

       To avoid	name conflicts with the	underlying system, atexit and  atexit-
       dont are	preprocessor macros defined as p9atexit	and p9atexitdont; see



Want to link to this manual page? Use this URL:

home | help