errno

Gamma: Version 4.0
Prev |  | Next

# `errno`

`errno` -- detects and numbers errors.

## Syntax

    errno ();

## Arguments

none

## Returns

The system error number.

## Description

When a function fails it returns a value and optionally sets the system error number. The `errno` function can be used to check the current error number. To check error numbers against constant error code in your program remember to include the file with: `require_lisp` ("Errno.lsp");.

| Calling the `errno` function in interactive mode does not return a valid number since you are retrieving the errno of the C function `printf` of the error to the screen (which will usually be 0).

## Example

In this example, we first define a function to remove a file. Then we call that function on a non-existing file to generate an error. Finally, we check the returned error code to get the error message.

        function remove_file(file)
        {
           unlink(file);
           errno();
        }

        Gamma> ret_val = remove_file("/tmp/xyz");
        2
        Gamma> strerror(2);
        "No such file or directory"
        Gamma>

## See Also

`error`, `strerror`

Prev | Home | Next
`block_signal`, `unblock_signal` | Up | `exec`

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