exit(2) 맨 페이지 - 윈디하나의 솔라나라

개요

섹션
맨 페이지 이름
검색(S)

exit(2)

exit(2)                          System Calls                          exit(2)

NAME
       exit, quick_exit, _Exit, _exit - terminate process

SYNOPSIS
       #include <stdlib.h>


       void exit(int status);


       void quick_exit(int status);


       void _Exit(int status);


       #include <unistd.h>


       void _exit(int status);

DESCRIPTION
       A  call  to  exit()  results  in normal program termination. The exit()
       function first calls all functions registered by atexit(3C), in the re‐
       verse order of their registration, except that a function is called af‐
       ter any previously registered functions that had already been called at
       the time it was registered. Each function is called as many times as it
       was registered. If, during the call to any such function, a call to the
       longjmp(3C) function is made that would terminate the call to the  reg‐
       istered function, the behavior is undefined.


       If  a  function registered by a call to atexit(3C) fails to return, the
       remaining registered functions are not  called  and  the  rest  of  the
       exit() processing is not completed. If exit() is called more than once,
       the effects are undefined.


       The  exit()  function  then  flushes  all  open  streams with unwritten
       buffered data, closes all open streams, and removes all  files  created
       by tmpfile(3C).


       Finally,  control  is  returned to the host environment by means of the
       function call _Exit(status).


       The quick_exit() function, and the related  at_quick_exit(3C)  function
       are specified in the C11 standard. The quick_exit() function is similar
       to  the  exit()  function  except  that  no open streams are flushed or
       closed when control is  returned  to  the  host  environment.  See  IN‐
       CITS/ISO/IEC 9899:2011.


       The  _Exit() and _exit() functions are functionally equivalent. They do
       not call functions registered with atexit(3C) or at_quick_exit(3C),  do
       not call any registered signal handlers, and do not flush open streams.


       The  _exit(),  _Exit(),  and  exit()  functions  terminate  the calling
       process with the following consequences:

           o      All of the file descriptors, directory  streams,  conversion
                  descriptors  and  message  catalogue descriptors open in the
                  calling process are closed.


           o      If the parent process of the calling process is executing  a
                  wait(3C), wait3(3C), waitid(2), or waitpid(3C), and has nei‐
                  ther  set  its SA_NOCLDWAIT flag nor set SIGCHLD to SIG_IGN,
                  it is notified of the calling process's termination and  the
                  low-order eight bits (that is, bits 0377) of status are made
                  available  to  it. If the parent is not waiting, the child's
                  status will be made available to it when the  parent  subse‐
                  quently executes wait(), wait3(), waitid(), or waitpid().


           o      If  the parent process of the calling process is not execut‐
                  ing a wait(), wait3(), waitid(), or waitpid(), and  has  not
                  set  its  SA_NOCLDWAIT  flag, or set SIGCHLD to SIG_IGN, the
                  calling process is transformed into a zombie process. A zom‐
                  bie process is an inactive process and it will be deleted at
                  some later time when its  parent  process  executes  wait(),
                  wait3(), waitid(), or waitpid(). A zombie process only occu‐
                  pies  a slot in the process table; it has no other space al‐
                  located either in user or kernel space.  The  process  table
                  slot  that  it  occupies is partially overlaid with time ac‐
                  counting information (see <sys/proc.h>) to be  used  by  the
                  times(2) function.


           o      Termination  of  a  process  does not directly terminate its
                  children. The sending of a SIGHUP signal as described  below
                  indirectly terminates children in some circumstances.


           o      A SIGCHLD will be sent to the parent process.


           o      The parent process ID of all of the calling process's exist‐
                  ing  child  processes and zombie processes is set to 1. That
                  is, these processes  are  inherited  by  the  initialization
                  process (see Intro(2)).


           o      Each mapped memory object is unmapped.


           o      Each  attached  shared-memory  segment  is  detached and the
                  value of shm_nattch (see shmget(2)) in  the  data  structure
                  associated with its shared memory ID is decremented by 1.


           o      For  each  semaphore for which the calling process has set a
                  semadj value (see semop(2)), that value is added to the sem‐
                  val of the specified semaphore.


           o      If the process is a controlling process, the  SIGHUP  signal
                  will be sent to each process in the foreground process group
                  of   the  controlling  terminal  belonging  to  the  calling
                  process.


           o      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.


           o      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 a SIGHUP signal followed by a SIGCONT
                  signal will be sent to each process  in  the  newly-orphaned
                  process group.


           o      If  the parent process has set its SA_NOCLDWAIT flag, or set
                  SIGCHLD to SIG_IGN, the status will be  discarded,  and  the
                  lifetime of the calling process will end immediately.


           o      If the process has process, text or data locks, an UNLOCK is
                  performed (see plock(3C) and memcntl(2)).


           o      All open named semaphores in the process are closed as if by
                  appropriate  calls to sem_close(3C). All open message queues
                  in the process are closed as  if  by  appropriate  calls  to
                  mq_close(3C).  Any  outstanding  asynchronous I/O operations
                  may be cancelled.


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


           o      An  extended  accounting  record  is written to the extended
                  process accounting file if the system's extended process ac‐
                  counting facility is enabled (see acctadm(8)).


           o      If the current process is the last process within  its  task
                  and if the system's extended task accounting facility is en‐
                  abled  (see  acctadm(8)),  an  extended accounting record is
                  written to the extended task accounting file.


RETURN VALUES
       These functions do not return.

ERRORS
       No errors are defined.

USAGE
       Normally applications should use exit() rather than _exit().

ATTRIBUTES
       See attributes(7) for descriptions of the following attributes:

       tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) ATTRIBUTE  TYPEAT‐
       TRIBUTE  VALUE  _  Interface StabilityCommitted _ MT-LevelSee below.  _
       StandardSee standards(7).



       The _exit() and _Exit() functions are Async-Signal-Safe.

SEE ALSO
       acct(2), close(2), Intro(2), memcntl(2),  semop(2),  shmget(2),  sigac‐
       tion(2),    times(2),    waitid(2),    at_quick_exit(3C),   atexit(3C),
       fclose(3C), mq_close(3C), plock(3C), tmpfile(3C), wait(3C),  wait3(3C),
       waitpid(3C), signal.h(3HEAD), attributes(7), standards(7), acctadm(8)

HISTORY
       The  quick_exit()  function  was added to Oracle Solaris in the Solaris
       11.4.0 release.


       The _Exit() function was added to Solaris in the Solaris  10  3/05  re‐
       lease.


       The exit() and _exit() functions have been included in all Sun and Ora‐
       cle releases of Solaris.

Oracle Solaris 11.4               30 Jan 2023                          exit(2)
맨 페이지 내용의 저작권은 맨 페이지 작성자에게 있습니다.
RSS ATOM XHTML 5 CSS3