Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

acct(2)

intro(2)

plock(2)

semop(2)

signal(2)

sigset(2)

wait(2)

EXIT(2)                              SysV                              EXIT(2)



NAME
     atexit, exit, _exit - terminate process

SYNOPSIS
     void _exit(status)
     int status;

     #include <stdlib.h>

     int atexit(void (*func)(void))

     void exit(status)
     int status;

DESCRIPTION
     The C function atexit registers the function pointed to by func, to be
     called without arguments at normal program termination.

     The C function exit terminates the process that called it, with the
     following consequences:

     o  All functions registered with the atexit function are called, in the
        reverse order of their registration.

     o  All open output streams are flushed, all open file descriptors are
        closed, and all files created with tmpfile are removed.

     o  If the parent process of the calling process is executing a wait, it
        is notified of the calling process' termination and the low order
        eight bits (that is, bits 0377) of status are made available to it
        (see wait(2)).

     o  If the parent process of the calling process is not executing a wait,
        the calling process is transformed into a "zombie process."; that is,
        one that 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 to be used by times (see <sys/proc.h>).

     o  The parent process ID of all of the calling processes' existing child
        processes and zombie processes is set to 1.  This means the
        initialization process (see intro(2)) inherits each of these
        processes.

     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.

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

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

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

     o  If the process ID, tty group ID, and process group ID of the calling
        process are equal, the SIGHUP signal is sent to each process that has
        a process group ID equal to that of the calling process.
     o  A death of child signal is sent to the parent.

     exit cleans up before the process exits.  _exit circumvents all clean-up.

SEE ALSO
     acct(2), intro(2), plock(2), semop(2), signal(2), sigset(2), wait(2).

DIAGNOSTICS
     atexit returns zero if the registration succeeds, nonzero if it fails.
     There can be no return from an exit system call.

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