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

Technical Reference: Base Operating System and Extensions, Volume 1

exit, atexit, _exit, 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;

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:

The _Exit subroutine is functionally equivalent to the _exit subroutine. The _Exit subroutine does not call functions registered with atexit or any registered signal handlers. The way the subroutine is implemented determines whether open streams are flushed or closed, and whether temporary files are removed. The calling process is terminated with the consequences described below.

Parameters

Status Indicates the status of the process. May be set to 0, EXIT_SUCCESS, EXIT_FAILURE, or any other value, though only the least significant 8 bits are available to a waiting parent 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.

Related Information

acct Subroutine, lockfx, lockf, flock, or lockf64 Subroutine, lockfx, lockf, flock, or lockf64 Subroutine, lockfx, lockf, flock, or lockf64 Subroutine, and getrusage, getrusage64, times, or vtimes Subroutine.

longjmp Subroutine, semop Subroutine, shmget Subroutine, sigaction, sigvec, or signal Subroutine, and wait, waitpid, or wait3 Subroutine in AIX 5L Version 5.2 Technical Reference: Base Operating System and Extensions Volume 2.

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

unistd.h in AIX 5L Version 5.2 Files Reference.

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