atexit

Gamma: Version 4.0
Prev |  | Next

# `atexit`

`atexit` -- evaluates code before exiting a program.

## Syntax

    atexit (code)

## Arguments

`code`

  Code to be evaluated.

## Returns

The result of evaluating `code`.

## Description

This function gives a program an opportunity to evaluate specified code before it exits. The `code` should be protected from evaluation using the quote operator `#`.

## Example

Running this program...

        #!/usr/cogent/bin/gamma

        // Program name: exiting.g
        // Demonstrates the atexit() function.

        atexit(#princ("Exiting now.\n"));
        princ("Started running...\n");
        princ("Still running.\n");
        exit_program(7);
        princ("You missed this part.\n");

...gives these results:

        [sh]$ exiting.g
        Started running...
        Still running.
        Exiting now.
        [sh]$

See the Starting Programs section in the Common Functions chapter (Tutorial One), or the Starting Programs section in the Common Functions for Any Program chapter (Tutorial Two) in the Cogent Tools Demo and Tutorials book for examples of this function used in context.

Prev | Home | Next
OS APIs | Up | `block_signal`, `unblock_signal`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.