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

FreeBSD Manual Pages


home | help
exit(2)			      System Calls Manual		       exit(2)

       exit, _exit - terminate process

       terminates  the calling process and passes status to the	system for in-
       spection, see wait(2).  Returning from main in a	C program has the same
       effect as the status value is the function value	returned by main (this
       value is	undefined if main does not take	care to	return a value	or  to
       call explicitly).

       If  the	calling	 process  is  multithreaded,  all  threads/lightweight
       process in the process will be terminated.

       cannot return to	its caller.  The result	of an call  during  exit  pro-
       cessing is undefined.

       The  functions  and  are	equivalent, except that	calls functions	regis-
       tered by	and flushes standard I/O buffers, while	does  not.   Both  and
       terminate the calling process with the following	consequences.  The ex-
       act order of these consequences is unspecified.

	      Functions	registered by (see atexit(3)) are  called  in  reverse
	      order of registration.

	      All file descriptors open	in the calling process are closed.

	      All files	created	by are removed (see tmpfile(3S)).

	      If  the  parent process of the calling process is	executing a or
	      it is notified of	the calling  process's	termination,  and  the
	      low-order	 eight bits; i.e., bits	0377 of	status are made	avail-
	      able to it (see wait(2)).

	      If the parent process of the calling process is not executing  a
	      or  and  does not	have set to 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 al-
	      located either in	user or	kernel space.  Time accounting	infor-
	      mation is	recorded for use by (see times(2)).

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

	      Threads/LWPs terminated by a call	to shall not invoke their can-
	      cellation	 cleanup  handlers  or	their thread specific data de-
	      structor functions.

	      Each attached shared memory segment is detached and the value of
	      in  the data structure associated	with its shared	memory identi-
	      fier is decremented by 1 (see shmop(2)).

	      For each semaphore for which the calling process has set	a  se-
	      madj  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  is  per-
	      formed, see plock(2).

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

	      A	signal is sent to the parent process.

	      If the calling process is	a controlling process, the  signal  is
	      sent to each process in the foreground process group of the con-
	      trolling terminal	belonging to the calling  process.   The  con-
	      trolling	terminal  associated with the session is disassociated
	      from the session,	allowing it to be acquired by a	 new  control-
	      ling process.

	      If the exit of the calling process causes	a process group	to be-
	      come orphaned, and if any	member of the  newly-orphaned  process
	      group  is	 stopped,  all processes in the	newly-orphaned process
	      group are	sent and signals.

	      If the current process has any child processes  that  are	 being
	      traced, they are sent a signal.

       was developed by	HP, AT&T, and the University of	California, Berkeley.

       acct(2),	     plock(2),	    pthread_cancel(3T),	     pthread_exit(3T),
       pthread_key_create(3T),	 semop(2),   shmop(2),	 times(2),   vfork(2),
       wait(2),	signal(5), sh(1), see exit conditions



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

home | help