81 lines · 1.6 KB · Text
RawDownload
.TH EXITS 2.SH NAMEexits, _exits, atexit, atexitdont, terminate \- terminate process, process cleanup.SH SYNOPSIS.B #include <u.h>.br.B #include <libc.h>.PP.nf.Bvoid	_exits(char *msg).Bvoid	exits(char *msg).PP.Bint	atexit(void(*)(void)).PP.Bvoid	atexitdont(void(*)(void)).fi.SH DESCRIPTION.I Exitsis the conventional way to terminate a process..I _Exitsis the underlying system call.Theycan never return..PP.I Msgconventionally includes a brief (maximum length.BR ERRLEN )explanation of the reason forexiting, or a null pointer or empty string to indicate normal termination.The string is passed to the parent process, prefixed by the name and processid of the exiting process, when the parent does a.IR wait (2)..PPBefore calling.I _exitswith.I msgas an argument,.I exitscalls in reverse order all the functionsrecorded by.IR atexit ..PP.I Atexitrecords.I fnas a function to be called by.IR 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,.I exitsonly calls those.IR atexit -registeredfunctions that were registered by the sameprocess as that calling.IR exits ..PPCalling.I atexittwice (or more) with the same function argument causes.I exitsto invoke the function twice (or more)..PPThere is a limit to the number of exit functionsthat will be recorded;.I atexitreturns 0 if that limit has been reached..PP.I Atexitdontcancels a previous registration of an exit function..SH SOURCE.B /sys/src/libc/port/atexit.c.SH "SEE ALSO".IR fork (2),.IR wait (2)