Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ exit(2) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

acct

sigaction, sigvec, signal

times

wait, waitpid



EXIT(2,L)                   AIX Technical Reference                   EXIT(2,L)



-------------------------------------------------------------------------------
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.  Since
    exit terminates the process, any errors encountered during these close
    operations go unreported.

  o If the parent process of the calling process is executing a wait system
    call, it is notified of the termination 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, waitpid."

  o If the parent process of the calling process is not executing a wait system
    call, and if the parent hasn't set its SIGCHLD 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 is set to -1.  This is done to avoid confusion between processes
    which are the real child processes of the init process and processes which
    are orphaned; this is useful in a Transparent Computing Facility cluster.
    getppid will return a 1 if the parent ID is -1 (see "getpid, getpgrp,
    getppid").  Zombie child processes of the exiting process are destroyed.

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




Processed November 7, 1990         EXIT(2,L)                                  1





EXIT(2,L)                   AIX Technical Reference                   EXIT(2,L)



  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 calling process is a session leader, 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.

    Note:  Note that since the C-shell starts each job in its own process
           group, jobs left in the background when a login csh exits, will not
           be sent SIGHUP.

  o If any child processes of the calling process are stopped, they are sent
    SIGHUP and SIGCONT signals.

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

The exit subroutine causes cleanup actions, including flushing of standard I/O
buffers, 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 SIGCHLD signal
       in the parent process.  See "sigaction, sigvec, signal."

RELATED INFORMATION

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

















Processed November 7, 1990         EXIT(2,L)                                  2



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