Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ exit(2) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

acct

signal

sigvec

times

wait

     exit, _exit

Purpose

     Terminates a process.

Syntax

     void exit (status)                        void _exit (status)
     int status;                               int status;
     Description

     The exit  system call terminates the  calling process and
     causes the following to occur:

     o   All  of  the file  descriptors  open  in the  calling
         process  are  closed.   If  Distributed  Services  is
         installed on your system, some  of these files may be
         remote.   Since  exit  terminates  the  process,  any
         errors encountered  during these close  operations go
         unreported.

     o   If the parent process of  the calling process is exe-
         cuting a wait system call, it is notified of the ter-
         mination  of the  calling process  and the  low-order
         eight bits (that is, bits 0377 or 0xFF) of status are
         made available to it.  See "wait."

     o   If the parent  process of the calling  process is not
         executing  a  wait system  call,  and  if the  parent
         hasn't  set its  SIGCLD signal  to SIG_IGN,  then the
         calling process is transformed into a zombie process.
         A zombie process is a process that occupies a slot in
         the process  table, but has no  other space allocated
         to it  either in user  or kernel space.   The process
         table  slot that  it occupies  is partially  overlaid
         with time  accounting information  to be used  by the
         times system  call.  (See "times" and  the sys/proc.h
         header file.)

     o   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 inherits
         each of these processes.

     o   Each attached  shared memory segment is  detached and
         the value of shm_nattach  in the data structure asso-
         ciated with  its shared  memory identifier  is decre-
         mented by 1.

     o   For each semaphore for  which the calling process has
         set a semadj value, that semadj value is added to the
         semval  of  the  specified semaphore.   (See  "semop"
         about semaphore operations.)

     o   If the process has a process lock, text lock, or data
         lock, an unlock is performed.  (See "plock.")

     o   An  accounting record  is written  on the  accounting
         file if  the system's accounting routine  is enabled.
         (See "acct" for information about enabling accounting
         routines.)

     o   If the process ID, tty group ID, and process group ID
         of  the calling  process are  equal, then  the SIGHUP
         signal is  sent to  each process  that has  a process
         group ID  equal to that  of the calling  process.  In
         other words, if  exit is called by  the process group
         leader  for the  controlling terminal  (typically the
         shell), then SIGHUP  is sent to all  of the processes
         associated with that terminal.

     o   Locks set by the lockf system call are removed.  (See
         "lockf" about file locks.)

     The  exit  subroutine  causes cleanup  actions  to  occur
     before the process exits.  The _exit system call bypasses
     all cleanup.

     Note:  The effect of exit  can be modified by the setting
     of the SIGCLD signal in the parent process.  See "signal"
     and "sigvec."

     Related Information

     In this book:  "acct,"  "signal," "sigvec," "times," and
     "wait."

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026