Files
Nils O. Selåsdal 1d26348bb0 iomux_signal.h and wqueue.h should be usable in C++. Add
to IOMux doxygen group too.
2015-12-04 22:18:29 +01:00

64 lines
1.8 KiB
C

#ifndef UC_IOMUX_SIGNAL_H_
#define UC_IOMUX_SIGNAL_H_
#include "ucore/iomux.h"
/** @addtogroup IOMux
* @{
*/
#ifdef __cplusplus
extern "C" {
#endif
/** 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);
#ifdef __cplusplus
}
#endif
/** @} (addtogroup)*/
#endif