exit_program

Gamma: Version 4.0
Prev |  | Next

# `exit_program`

`exit_program` -- terminates the interpreter.

## Syntax

    exit_program (return_value)

## Arguments

`return_value`

  An integer value to be returned to the operating system when the program exits.

## Returns

This function does not return.

## Description

Terminate the interpreter immediately and return the provided integer value to the operating system as an exit code.

## Example

Running this program...

        #!/usr/cogent/bin/gamma

        //Program: exiting.g

        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:

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

        Exit showing abnormal termination of -1 (255) to the operating system.

        exit_program(-1);

        />echo $?
        255
        />

See the Kill a Child Process section of the Common Functions for Any Program chapter (Tutorial Two) in the Cogent Tools Demo and Tutorials book for an example of this function used in context.

Prev | Home | Next
`exec` | Up | `fork`

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