Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch introduces some limited support for error handling in a POSIX environment. A partial interface to the POSIX system calls is included as part of the implementation of this feature. An internal global logical flag, `ignore_fatal` is added to the `MOM_error_handler` module which controls the behavior of `FATAL` errors. If true, then `FATAL` errors trigger a signal (here `SIGUSR1`) which call a handler which restores the program to the earlier state. This change allows us to test `FATAL` errors at runtime without stopping program execution, so that we can cycle through multiple errors. This feature is toggled with two new functions, `disable_fatal_errors()` and `enable_fatal_errors()`. This is implemented in part using POSIX system calls from the C standard library (libc), using the C interoperability layer. Details which are unspecified by the POSIX standard, such as the definitions of signals or the datatype size, are defined in a header (`posix.h`) which can be optionally configured at compile-time. The header defaults to use typical Linux POSIX values, and may be configured by autoconf for more exotic platforms in a later patch. The previous state is set and restored by the `setjmp`/`longjmp` (or `sigsetjmp`/`siglongjmp`) functions. Although these functions behave as expected on all tested platforms, a code which uses these functions is not standards-conforming. If issues arise in the future, error handling may not be available on those platforms, and compile-time configuration may be required to disable these features. No existing code is using these features, but are expected to be part of a future patch. Error handler API: * `disable_fatal_errors` * `enable_fatal_errors` New POSIX API: * `chmod` * `signal` * `kill` * `getpid` * `getppid` * `sleep` * `setjmp` * `sigsetjmp` * `longjmp` * `siglongjmp` New derived types: * `jmp_buf` * `sigjmp_buf` New interface (for signal handlers): * `handler_interface` New compile-time macros: * `JMP_BUF_SIZE` * `SIGJMP_BUF_SIZE` * `SIGSETJMP_NAME` * `POSIX_SIGUSR1`
- Loading branch information