When an error occurs during a call to any of the HP C RTL
functions, the function returns an unsuccessful status. Many RTL
routines also set the external variable
errno
to a value that indicates the reason for the failure. You should always
check the return value for an error situation.

The
<errno.h>
header file declares
errno
and symbolically defines the possible error codes. By including the
<errno.h>
header file in your program, you can check for specific error codes
after a HP C RTL function call.

At program startup, the value of
errno
is 0. The value of
errno
can be set to a nonzero value by many HP C RTL functions. It is
not reset to 0 by any HP C RTL function, so it is only valid to use
errno
after a HP C RTL function call has been made and a failure status
returned. Table 4-2 lists the symbolic values that may be assigned
to
errno
by the HP C RTL.

You can translate the error codes to a message, similar to that found in
UNIX systems, by using the
perror
or
strerror
function. If
errno
is set to EVMSERR,
perror
cannot translate the error code and prints the following message,
followed by the OpenVMS error message associated with the value:

%s:nontranslatable vms error code: xxxxxx vms message:

In the message, %s is the string you supply to
perror
; xxxxxx is the OpenVMS condition value.

If
errno
is set to EVMSERR, then the OpenVMS condition value is available in the
vaxc$errno
variable declared in the
<errno.h>
header file. The
vaxc$errno
variable is guaranteed to have a valid value only if
errno
is set to EVMSERR; if
errno
is set to a value other than EVMSERR, the value of
vaxc$errno
is undefined.

See the
strerror
function in the Reference Section for another way to translate error
codes.

Both OpenVMS and UNIX systems provide signal-handling mechanisms that
behave differently but use similar terminology. With the HP C RTL,
you can program using either signal-handling mechanism. Before
describing the signal-handling routines, some terminology must be
established.

The UNIX term for a software interrupt is signal. A routine
called by the UNIX system to process a signal is termed a signal
handler.

A software interrupt on an OpenVMS system is referred to as a
signal, condition, or exception. A routine
called by the OpenVMS system to process software interrupts is termed a
signal handler, condition handler, or exception
handler.

To prevent confusion, the terms signal and signal
handler in this manual refer to UNIX interrupts and interrupt
processing routines, while the terms exception and
exception handler refer to OpenVMS interrupts and interrupt
processing routines.

Signals are represented by mnemonics defined in the
<signal.h>
header file. Table 4-3 lists the supported signal mnemonics and the
corresponding event that causes each signal to be generated on the
OpenVMS operating system.

1Cannot be reset when caught.
2Cannot be caught or ignored.
3Cannot be blocked.
4Setting SIGINT can affect processing of Ctrl/Y interrupts.
For example, in response to a caller's request to block or ignore
SIGINT, the HP C RTL disables the Ctrl/Y interrupt.
5"Not implemented" for SIGQUIT means that there is no
external event, including a Ctrl/Y interrupt, that would trigger a
SIGQUIT signal, thereby causing a signal handler established for
SIGQUIT to be invoked. This signal can be generated only through an
appropriate HP C RTL function, such as raise.
6Supported on OpenVMS Version 7.3 and higher.

By default, when a signal (except for SIGCHLD) occurs, the process is
terminated. However, you can choose to have the signal ignored by using
one of the following functions:

sigactionsignalsigvecssignal

You can have the signal blocked by using one of the following functions:

You can also establish a signal handler to catch and process a signal
by using one of the following functions:

sigactionsignalsigvecssignal

Unless noted in Table 4-3, each signal can be reset. A signal is
reset if the signal handler function calls
signal
or
ssignal
to re-establish itself to catch the signal. Example 4-1 shows how to
establish a signal handler and reset the signal.

The calling interface to a signal handler is:

void handler (int sigint);

Where sigint is the signal number of the raised signal that
caused this handler to be called.