Library /sys$common/syshlp/helplib.hlb  —  CRTL  exit,_exit
    Terminate execution of the program from which they are called.
    These functions are nonreentrant.

    Format

      #include  <stdlib.h>

      void exit  (int status);

      #include  <unistd.h>

      void _exit  (int status);

1  –  Argument

 status

    For non-POSIX behavior, a status value of EXIT_SUCCESS (1), EXIT_
    FAILURE (2), or a number from 3 to 255, as follows:

    o  A status value of 0, 1 or EXIT_SUCCESS is translated to the
       OpenVMS SS$_NORMAL status code to return the OpenVMS success
       value.

    o  A status value of 2 or EXIT_FAILURE is translated to an error-
       level exit status. The status value is passed to the parent
       process.

    o  Any other status value is left the same.

    For POSIX behavior:

    o  A status value of 0 is translated to the OpenVMS SS$_NORMAL
       status code to return the OpenVMS success value.

    o  Any other status is returned to the parent process as an
       OpenVMS message symbol with facility set to C, severity
       set to success, and with the status in the message number
       field. For more information on the format of message symbols,
       see "message code" in the VSI OpenVMS Command Definition,
       Librarian, and Message Utilities Manual.

    To get POSIX behavior, include <unistd.h> and compile with the
    _POSIX_EXIT feature-test macro set (either with /DEFINE=_POSIX_
    EXIT, or with #define _POSIX_EXIT at the top of your file, before
    any file inclusions). This behavior is available only on OpenVMS
    Version 7.0 and higher systems.

2  –  Description

    If the process was invoked by DCL, the status is interpreted by
    DCL, and a message is displayed.

    If the process was a child process created using vfork or an exec
    function, then the child process exits and control returns to the
    parent. The two functions are identical; the _exit function is
    retained for reasons of compatibility with VAX C.

    The exit and _exit functions make use of the $EXIT system
    service. If your process is being invoked by the RUN command
    using any of the hibernation and scheduled wakeup qualifiers, the
    process might not correctly return to hibernation state when an
    exit or _exit call is made.

    The C compiler command-line qualifier /[NO]MAIN=POSIX_EXIT can be
    used to direct the compiler to call __posix_exit instead of exit
    when returning from main. The default is /NOMAIN.

    Beginning with OpenVMS Version 8.3, C RTL contains a fix for
    the problem in which a call to _exit after a failed execl really
    exits but must not.

    In the OpenVMS implementation of vfork, a child process is not
    actually started as it is started on most UNIX systems. However,
    the C RTL creates some internal data structures intended to mimic
    child-process functionality (called the "child context").

    A bug occurred whereby after a vfork while in the child context,
    a call to an exec function justifiably fails, then calls _exit.
    On UNIX systems, after the failed exec call, the child process
    continues to execute. A subsequent call to _exit terminates
    the child. In the OpenVMS implementation, after the failed exec
    call, the child context terminates. A subsequent call to _exit
    terminates the parent. The C RTL fix is enabled by a feature
    logical switch, DECC$EXIT_AFTER_ FAILED_EXEC. Enabling this
    feature logical allows the child context to continue execution.

    With DECC$EXIT_AFTER_FAILED_EXEC disabled or not defined, the
    current behavior remains the default.

                                   NOTE

       EXIT_SUCCESS and EXIT_FAILURE are portable across any
       ANSI C compiler to indicate success or failure. On OpenVMS
       systems, they are mapped to OpenVMS condition codes with
       the severity set to success or failure, respectively. Values
       in the range of 3 to 255 can be used by a child process to
       communicate a small amount of data to the parent. The parent
       retrieves this data using the wait, wait3, wait4, or waitpid
       functions.
Close Help