*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> standard/exit (2)              


exit(2)								       exit(2)

NAME    [Toc]    [Back]

     exit, _exit - terminate process

C SYNOPSIS    [Toc]    [Back]

     #include <stdlib.h>

     void exit(int status);

     #include <unistd.h>

     void _exit(int status);

DESCRIPTION    [Toc]    [Back]

     The C library routine exit, which is discussed at the end of this
     section, invokes the system routine _exit upon completion of its own
     cleanup chores.  _exit terminates the calling process with	the following

	  All of the file descriptors, directory streams and message catalogue
	  descriptors open in the calling process are closed. If the process
	  is sharing file descriptors via an sproc, other members of the share
	  group	do NOT have their file descriptors closed.

	  A SIGCHLD signal is sent to the calling process's parent process.

	  If the parent	process	of the calling process has not specified the
	  SA_NOCLDWAIT flag [see sigaction(2)],	the calling process is
	  transformed into a ``zombie process.''  A zombie process is a
	  process that only occupies a slot in the process table.  It has no
	  other	space allocated	either in user or kernel space.	 The process
	  table	slot that it occupies is partially overlaid with time
	  accounting information [see <sys/proc.h>] to be used by the times
	  system call.

	  The parent process ID	of all of the calling process's	existing child
	  processes  and zombie	processes is set to 1.	This means the
	  initialization process [see intro(2)]	inherits each of these

	  If the process belongs to a share group, it is removed from that
	  group.  Its stack segment is deallocated and removed from the	share
	  group's virtual space.  All other virtual space that was shared with
	  the share group is left untouched.  If the prctl (PR_SETEXITSIG)
	  option has been enabled for the share	group, than the	specified
	  signal is sent to all	remaining share	group members.

	  Each attached	shared memory segment is detached and the value	of
	  shm_nattach in the data structure associated with its	shared memory
	  identifier is	decremented by 1.

									Page 1

exit(2)								       exit(2)

	  For each semaphore for which the calling process has set a semadj
	  value	[see semop(2)],	that semadj value is added to the semval of
	  the specified	semaphore.

	  If the process has a process,	text, or data lock, an unlock is
	  performed [see plock(2)].  If	the process has	any pages locked, they
	  are unlocked [see mpin(2)].

	  An accounting	record is written on the accounting file if the
	  system's accounting routine is enabled [see acct(2)].

	  If the process is a controlling process, SIGHUP is sent to the
	  foreground process group of its controlling terminal and its
	  controlling terminal is deallocated.

	  If the calling process has any stopped children whose	process	group
	  will be orphaned when	the calling process exits, or if the calling
	  process is a member of a process group that will be orphaned when
	  the calling process exits, that process group	will be	sent SIGHUP
	  and SIGCONT signals.	Note that these	signals	are not	sent if	the
	  process became the process group leader through the invocation of
	  the setpgrp(2) system	call.

	  In all cases,	if the calling process is a process group leader and
	  has an associated controlling	terminal, the controlling terminal is
	  disassociated	from the process allowing it to	be acquired by another
	  process group	leader.

	  Any mapped files are closed and any written pages flushed to disk.

     The C function exit(3C) calls any functions registered through the	atexit
     function in the reverse order of their registration.  It then causes each
     buffered file stream to be	flushed, and, unless an	sproc has been
     executed, closed.	The function _exit circumvents all such	functions and

     The symbols EXIT_SUCCESS and EXIT_FAILURE are defined in stdlib.h and may
     be	used as	the value of status to indicate	successful or unsuccessful
     termination, respectively.

SEE ALSO    [Toc]    [Back]

     acct(2), intro(2),	plock(2), semop(2), sigaction(2), signal(2), mmap(2),
     mpin(2), prctl(2),	sigprocmask(2),	sigvec(3B), sigblock(3B),
     sigsetmask(3B), times(2), wait(2),	atexit(3C).

NOTES    [Toc]    [Back]

     See signal(2) NOTES.

									PPPPaaaaggggeeee 2222
[ Back ]
 Similar pages
Name OS Title
kill HP-UX send a signal to a process; terminate a process
_exit Tru64 Terminate a process
exit Tru64 Terminate a process
atexit Tru64 Terminate a process
_exit OpenBSD terminate the calling process
kill OpenBSD terminate or signal a process
_exit FreeBSD terminate the calling process
kill FreeBSD terminate or signal a process
_exit NetBSD terminate the calling process
_exit Linux terminate the current process
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service