10.4. Communication with the Environment

10.4.1. The abort function

Synopsis
#include <stdlib.h>

void abort ( void );

Description

The abort function causes abnormal termination to occur unless the signal SIGABRT is being caught and the signal handler does not return. Whether open output streams are flushed or open streams are closed or temporary files removed is implementation-defined. An implementation-defined form of the status unsuccessful termination is returned to the host environment by means of the function call raise(SIGABRT).

Returns

The abort function cannot return to its caller.

Implementation Notes
See Also

Section 7.2.1

10.4.2. The atexit function

Synopsis
#include <stdlib.h>

void atexit (void (*func)(void) );

Description

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

Implementation Limits

The implementation shall support the registration of at least 32 functions.

Returns

The atexit function returns zero if the registration succeeds, nonzero if it fails.

Implementation Notes

10.4.3. The exit function

Synopsis
#include <stdlib.h>

void exit (int status );

Description

The exit function causes normal program termination to occur. If more than one call to the exit function is executed by a program, the behavior is undefined.

First, all functions registered by the atexit function are called, in the reverse order of their registration.

Next, all open streams with unwritten buffered data are flushed, all open streams are closed, and all files created by the tmpfile function are removed.

Finally, control is returned to the host environment. If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. If the value of status is EXIT_FAILURE, and implementation-defined form of the status unsuccessful termination is returned. Otherwise the status returned is implementation-defined.

Returns

The exit function cannot return to its caller.

Implementation Notes

10.4.4. The system function

Synopsis
#include <stdlib.h>

int system (const char * string );

Description

The system function passes the string pointed to by string to the host environment to be executed by a command processor in an implementation-defined manner. A null pointer may be used for string to inquire whether a command processor exists.

Returns

If the argument is a null pointer, the system function returns nonzero only if a command processor is available. If the argument is not a null pointer, the system function returns an implementation-defined value.

Implementation Notes