csomh / source-git / rpm

Forked from source-git/rpm 4 years ago
Clone
2ff057
#ifndef	H_RPMSQ
2ff057
#define	H_RPMSQ
2ff057
2ff057
/** \ingroup rpmio
2ff057
 * \file rpmio/rpmsq.h
2ff057
 *
2ff057
 * Signal Queue API
2ff057
 */
2ff057
#include <rpm/rpmsw.h>
2ff057
#include <signal.h>
2ff057
2ff057
#ifdef __cplusplus
2ff057
extern "C" {
2ff057
#endif
2ff057
2ff057
/** \ingroup rpmsq
2ff057
 * Default signal handler prototype.
2ff057
 * @param signum	signal number
2ff057
 * @param info		(siginfo_t) signal info
2ff057
 * @param context	signal context
2ff057
 */
2ff057
typedef void (*rpmsqAction_t) (int signum, siginfo_t * info, void * context);
2ff057
2ff057
/** \ingroup rpmsq
2ff057
 *  SIG_DFL, SIG_IGN and SIG_ERR counterparts
2ff057
 */
2ff057
#define RPMSQ_DFL	((rpmsqAction_t)0)
2ff057
#define RPMSQ_IGN	((rpmsqAction_t)1)
2ff057
#define RPMSQ_ERR	((rpmsqAction_t)-1)
2ff057
2ff057
/** \ingroup rpmsq
2ff057
 * Test if given signal has been caught (while signals blocked).
2ff057
 * Similar to sigismember() but operates on internal signal queue.
2ff057
 * @param signum	signal to test for
2ff057
 * @return		1 if caught, 0 if not and -1 on error
2ff057
 */
2ff057
int rpmsqIsCaught(int signum);
2ff057
2ff057
/** \ingroup rpmsq
2ff057
 * Activate (or disable) the signal queue.
2ff057
 * @param state		1 to enable, 0 to disable
2ff057
 * @return		0 on success, negative on error
2ff057
 */
2ff057
int rpmsqActivate(int state);
2ff057
2ff057
/** \ingroup rpmsq
2ff057
 * Set or delete a signal handler for a signal.
2ff057
 * @param signum	signal number
2ff057
 * @param handler	signal handler or NULL to delete
2ff057
 * @return		previous handler, RPMSQ_ERR on error
2ff057
 */
2ff057
rpmsqAction_t rpmsqSetAction(int signum, rpmsqAction_t handler);
2ff057
2ff057
/** \ingroup rpmsq
2ff057
 * Block or unblock (almost) all signals.
2ff057
 * The operation is "reference counted" so the calls can be nested,
2ff057
 * and signals are only unblocked when the reference count falls to zero.
2ff057
 * @param op		SIG_BLOCK/SIG_UNBLOCK
2ff057
 * @return		0 on success, -1 on error
2ff057
 */
2ff057
int rpmsqBlock(int op);
2ff057
2ff057
/** \ingroup rpmsq
2ff057
 * Poll for caught signals, executing their handlers.
2ff057
 * @return		no. active signals found
2ff057
 */
2ff057
int rpmsqPoll(void);
2ff057
2ff057
void rpmsqSetInterruptSafety(int on);
2ff057
2ff057
#ifdef __cplusplus
2ff057
}
2ff057
#endif
2ff057
2ff057
#endif	/* H_RPMSQ */