Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ atexit(S) — System V/386 Software Development System 3.2.2b

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     ATEXIT(S)                 UNIX System V                 ATEXIT(S)



     Name
          atexit - calls a process at termination

     Syntax
          #include <stdlib.h>

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

     Description
          The atexit function is passed the address of a function
          (func) to be called when the program terminates normally.
          Successive calls to atexit create a register of functions
          that are executed ``last in, first out.'' No more than 32
          functions can be registered with atexit. The functions
          passed to atexit cannot take parameters.

     Return Value
          atexit returns a pointer to the function if successful, or
          NULL if there is no space left to store the function
          pointer.

     See Also
          abort(S), exit(S)

     Example
          #include <stdlib.h>
          #include <stdio.h>

          main( )
           {
                   int fn1( ), fn2( ), fn3( ), fn4( );
                   atexit(fn1);
                   atexit(fn2);
                   atexit(fn3);
                   atexit(fn4);
                   printf("This is executed first.\n");
           }

          int fn1( )
           {
                   printf("next.\n");
           }

          int fn2( )
           {
                   printf("executed ");
           }

           int fn3( )
           {
                   printf("is ");
           }

          int fn4( )
           {
                   printf("This ");
           }

          Output:

            This is executed first.
            This is executed next.

          This program pushes four functions onto the stack of
          functions to be executed when atexit is called. When the
          program exits, these programs are executed on a last-in,
          first-out basis.


     Standards Conformance
          atexit is conformant with:
          ANSI X3.159-198X C Language Draft Standard, May 13, 1988.


                                                (printed 6/20/89)



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