libamxp
1.4.0
Patterns C Implementation
|
Provides functionality to translate Linux System Signals to Ambiorix signal/slot mechanism. More...
Macros | |
#define | AMXP_SYSSIG_MAX 32 |
Defines highest possible system signal. More... | |
Functions | |
int | amxp_syssig_enable (const int sigid, const bool enable) |
Enables or disables monitoring of a system signal. More... | |
bool | amxp_syssig_is_enabled (const int sigid) |
Checks if a system signal is being monitored. More... | |
int | amxp_syssig_get_fd (void) |
Returns a file descriptor that can be used in an eventloop. More... | |
int | amxp_syssig_read (void) |
Reads from the file descriptor. More... | |
Provides functionality to translate Linux System Signals to Ambiorix signal/slot mechanism.
Handling system signals using the system provided methods have some limitations. In a system signal handler the set of possible system calls that can be done is very limited.
The Ambiorix System Signal API translates a system signal to an Ambiorix signal. To such a signal you can connect many slots (callback functions).
For more information about Ambiorix Signal/Slots
#define AMXP_SYSSIG_MAX 32 |
Defines highest possible system signal.
Definition at line 95 of file amxp_syssig.h.
int amxp_syssig_enable | ( | const int | sigid, |
const bool | enable | ||
) |
Enables or disables monitoring of a system signal.
When a system signal gets enabled, the signal name is added to the global Ambiorix signal manager. The name of the signal is retrieved using strsignal function.
After enabling a signal it is possible to connect slots (callback) functions to it using amxp_slot_connect.
The name of the signal can be retrieved using "strsignal(sigid)".
sigid | id of the system signal example SIGUSR1 |
enable | true to enable monitoring, false to stop monitoring |
Definition at line 70 of file amxp_syssig.c.
int amxp_syssig_get_fd | ( | void | ) |
Returns a file descriptor that can be used in an eventloop.
System signal monitoring is done using "signalfd". The filedescriptor must be added to your eventloop to make it work. When data is available on this filedescriptor the function amxp_syssig_read must be called to make sure the correct dispatching is done (calling of the slots)
Definition at line 110 of file amxp_syssig.c.
bool amxp_syssig_is_enabled | ( | const int | sigid | ) |
Checks if a system signal is being monitored.
If a system signal is enabled for monitoring this function will return true.
sigid | id of the system signal example SIGUSR1 |
Definition at line 97 of file amxp_syssig.c.
int amxp_syssig_read | ( | void | ) |
Reads from the file descriptor.
Use this function in an eventloop. When a system signal is received data will become available for read on the signal fd. Use amxp_syssig_get_fd to get the file descriptor and add it to your eventloop.
This function will make sure that all data is read from the file descriptor and that the correct slots are called.
Definition at line 114 of file amxp_syssig.c.