Unix/Linux Go Back    

Plan 9 - man page for exits (plan9 section 2)

Linux & Unix Commands - Search Man Pages
Man Page or Keyword Search:   man
Select Man Page Set:       apropos Keyword Search (sections above)

EXITS(2)										 EXITS(2)

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

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

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

       int  atexit(void(*)(void))

       void atexitdont(void(*)(void))

       /* Alef only */

       void _exits(byte *msg)

       void exits(byte *msg)

       void terminate(byte *msg)

       Exits  is  the  conventional  way to terminate a process.  _Exits is the underlying system
       call.  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 indicate 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 wait(2).

       Before  calling _exits with msg as an argument, exits calls in reverse order all the func-
       tions 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.

       In  Alef,  the system call _exits is the same, but its use is discouraged because the run-
       time system needs to maintain consistency; terminate and exits are  the	recommended  rou-
       tines.	Terminate is called automatically when a task or proc returns from its main func-
       tion; it may also be called explicitly.	In either case, it frees resources private to the
       task  (which  may be the implicit main task within the proc) and terminates that task.  If
       that task is the last one in the proc, resources private to the proc are then  freed.   If
       that  proc is the last one in the program, it calls exits.  Exits should only be called in
       the last proc of a program; it calls any atexit functions (registered  by  any  proc)  and
       then calls _exits.

       In Alef, atexit and atexitdont behave the same as in C.


       fork(2), wait(2)

Unix & Linux Commands & Man Pages : ©2000 - 2018 Unix and Linux Forums

All times are GMT -4. The time now is 12:55 PM.