Add unix signal integration with the iomux
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#ifndef UC_IOMUX_SIGNAL_H_
|
||||
#define UC_IOMUX_SIGNAL_H_
|
||||
|
||||
#include "ucore/iomux.h"
|
||||
/** Callback signature for handling unix signals.
|
||||
* @param mux associated mux
|
||||
* @param signo unix signal number
|
||||
* @param cookie value passed to iomux_register_unixsignal
|
||||
*/
|
||||
typedef void (*IOMuxSignalHandler)(struct IOMux *mux, int signo, void *cookie);
|
||||
|
||||
|
||||
/** Register a handler for a unix signal.
|
||||
* The handler is invoked as normally within the iomux loop.
|
||||
* Note, only one handler per signal can be used.
|
||||
*
|
||||
* The current implementation has the limitation that only
|
||||
* one IOMux can globally be registered to handle signals.
|
||||
* All signals must be unregistered prior to deleting the
|
||||
* IOMux that is set up to handle signals.
|
||||
*
|
||||
* @param mux associated IOMux
|
||||
* @param signo the signal (see man signal) to handle
|
||||
* @param handler callback that will be called whrn the signal is caught
|
||||
* @param cookie value passed back to the handler
|
||||
*
|
||||
* @return 0 on success, errno if registring the signal failed.
|
||||
* (EINVAL if another mux is registered for signals,
|
||||
* EEXISTS if a signal handler is already registered for the signo
|
||||
* ENOMEM if memory allocation failed
|
||||
* other errno values from syscalls)
|
||||
*
|
||||
*/
|
||||
int iomux_register_unixsignal(struct IOMux *mux,
|
||||
int signo,
|
||||
IOMuxSignalHandler handler,
|
||||
void *cookie);
|
||||
|
||||
/** Unregister the current handler for a signal.
|
||||
*
|
||||
* @param mux associated mux
|
||||
* @param signo signal number handler to unregister
|
||||
* @return 0 on success, errno value on failure (ENOENT if
|
||||
* no signal handler was registered for signo)
|
||||
*/
|
||||
int iomux_unregister_unixsignal(struct IOMux *mux, int signo);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user