| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- terminate process
#include <stdlib.h>voidexit(intstatus);
void_Exit(intstatus);
#include <unistd.h>void_exit(intstatus);
Theexit() function first calls all functions registered byatexit(3C), in thereverse order of their registration, except that a function is called after anypreviously registered functions that had already been called at the time itwas registered. Each function is called as many times as it wasregistered. If, during the call to any such function, a call tothelongjmp(3C) function is made that would terminate the call to theregistered function, the behavior is undefined.
If a function registered by a call toatexit(3C) fails to return,the remaining registered functions are not called and the rest of theexit() processing is not completed. Ifexit() is called more than once, theeffects are undefined.
Theexit() function then flushes all open streams with unwritten buffered data,closes all open streams, and removes all files created bytmpfile(3C).
The_Exit() and_exit() functions are functionally equivalent. They do not callfunctions registered withatexit(), do not call any registered signal handlers, anddo not flush open streams.
The_exit(),_Exit(), andexit() functions terminate the calling process with thefollowing consequences:
All of the file descriptors, directory streams, conversion descriptors and message catalogue descriptors open in the calling process are closed.
If the parent process of the calling process is executing await(3C),wait3(3C),waitid(2), orwaitpid(3C), and has neither set itsSA_NOCLDWAIT flag nor setSIGCHLD toSIG_IGN, it is notified of the calling process's termination and the low-order eight bits (that is, bits 0377) ofstatus are made available to it. If the parent is not waiting, the child's status will be made available to it when the parent subsequently executeswait(),wait3(),waitid(), orwaitpid().
If the parent process of the calling process is not executing await(),wait3(),waitid(), orwaitpid(), and has not set itsSA_NOCLDWAIT flag, or setSIGCHLD toSIG_IGN, the calling process is transformed into azombie process. Azombie process is an inactive process and it will be deleted at some later time when its parent process executeswait(),wait3(),waitid(), orwaitpid(). A zombie process 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 thetimes(2) function.
Termination of a process does not directly terminate its children. The sending of aSIGHUP signal as described below indirectly terminates children in some circumstances.
ASIGCHLD will be sent to the parent process.
The parent process ID of all of the calling process's existing child processes and zombie processes is set to 1. That is, these processes are inherited by the initialization process (seeIntro(2)).
Each mapped memory object is unmapped.
Each attached shared-memory segment is detached and the value ofshm_nattch (seeshmget(2)) in the data structure associated with its shared memory ID is decremented by 1.
For each semaphore for which the calling process has set asemadj value (seesemop(2)), that value is added to thesemval of the specified semaphore.
If the process is a controlling process, theSIGHUP signal will be sent to each process in the foreground process group of the controlling terminal belonging to the calling process.
If the process is a controlling process, the controlling terminal associated with the session is disassociated from the session, allowing it to be acquired by a new controlling process.
If the exit of the process causes a process group to become orphaned, and if any member of the newly-orphaned process group is stopped, then aSIGHUP signal followed by aSIGCONT signal will be sent to each process in the newly-orphaned process group.
If the parent process has set itsSA_NOCLDWAIT flag, or setSIGCHLD toSIG_IGN, the status will be discarded, and the lifetime of the calling process will end immediately.
If the process has process, text or data locks, anUNLOCK is performed (seeplock(3C) andmemcntl(2)).
All open named semaphores in the process are closed as if by appropriate calls tosem_close(3C). All open message queues in the process are closed as if by appropriate calls tomq_close(3C). Any outstanding asynchronous I/O operations may be cancelled.
An accounting record is written on the accounting file if the system's accounting routine is enabled (seeacct(2)).
An extended accounting record is written to the extended process accounting file if the system's extended process accounting facility is enabled (seeacctadm(1M)).
If the current process is the last process within its task and if the system's extended task accounting facility is enabled (seeacctadm(1M)), an extended accounting record is written to the extended task accounting file.
These functions do not return.
No errors are defined.
Normally applications should useexit() rather than_exit().
Seeattributes(5) for descriptions of the following attributes:
|
The_exit() and_Exit() functions are Async-Signal-Safe.
acctadm(1M),Intro(2),acct(2),close(2),memcntl(2),semop(2),shmget(2),sigaction(2),times(2),waitid(2),atexit(3C),fclose(3C),mq_close(3C),plock(3C),signal.h(3HEAD),tmpfile(3C),wait(3C),wait3(3C),waitpid(3C),attributes(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |