This section explains how contingency and STXIT routines can be implemented in C.
Familiarity with the concept of contingency and STXIT routines is essential to understanding the material presented here.These concepts and the related BS2000 system macros are described in detail in the manual "Executive Macros" [10 (Related publications)].
The library functions mentioned in this section (signal()
, raise()
, alarm()
, cenaco()
, cdisco(), cstxit(), longjmp(),
setjmp()
) are explained at length in the reference section of this manual.
Important
The use of some C library functions from within STXIT routines may result in undefined behavior. Consistency in the library functions cannot always be guaranteed in the event of asynchronous interrupts. Undefined behavior results if the same library function or a library function belonging to the same group (see list below) as the one asynchronously interrupted by the STXIT event is to be executed within the STXIT routine.
The "critical" C library functions in connection with asynchronous interrupts are as follows:
file access functions for opening and closing files:
fopen(),freopen(), open(), creat(), fclose(), close()
all file access, file management and input/output functions applied on the same file
functions that generate random numbers:
rand()
,srand()
time functions:
localtime()
,gmtime()
functions for enabling and disabling contingency routines:
cenaco(), cdisco()
atexit()
strtok()
setlocale()
input/output functions from the C++ standard library