[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1


exit, atexit, or _exit Subroutine

Purpose

Terminates a process.

Library

Standard C Library (libc.a)

Syntax

#include <stdlib.h>


void exit ( Status)
int Status;


void _exit ( Status)
int Status;

#include <sys/limits.h>


int atexit ( Function)
void (*Function) (void);

Description

The exit subroutine terminates the calling process after calling the standard I/O library _cleanup function to flush any buffered output. Also, it calls any functions registered previously for the process by the atexit subroutine. The atexit subroutine registers functions called at normal process termination for cleanup processing. Normal termination occurs as a result of either a call to the exit subroutine or a return statement in the main function.

Each function a call to the atexit subroutine registers must return. This action ensures that all registered functions are called.

Finally, the exit subroutine calls the _exit subroutine, which completes process termination and does not return. The _exit subroutine terminates the calling process and causes the following to occur:

Parameters


Status Indicates the status of the process.
Function Specifies a function to be called at normal process termination for cleanup processing. You may specify a number of functions to the limit set by the ATEXIT_MAX function, which is defined in the sys/limits.h file. A pushdown stack of functions is kept so that the last function registered is the first function called.

Return Values

Upon successful completion, the atexit subroutine returns a value of 0. Otherwise, a nonzero value is returned. The exit and _exit subroutines do not return a value.

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The acct (acct Subroutine) subroutine, lockfx (lockfx, lockf, flock, or lockf64 Subroutine), lockf (lockfx, lockf, flock, or lockf64 Subroutine), or flock (lockfx, lockf, flock, or lockf64 Subroutine) subroutines, sigaction, sigvec, or signal subroutine, times (getrusage, getrusage64, times, or vtimes Subroutine) subroutine, wait, waitpid, or wait3 subroutine.

Asynchronous I/O Overview in AIX 5L Version 5.1 Kernel Extensions and Device Support Programming Concepts.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]