/** \ingroup rpmio
* \file rpmio/rpmsq.h
*
+ * Signal Queue API
*/
#include <rpm/rpmsw.h>
#include <signal.h>
* @param info (siginfo_t) signal info
* @param context signal context
*/
-#ifdef SA_SIGINFO
typedef void (*rpmsqAction_t) (int signum, siginfo_t * info, void * context);
-#else
-typedef void (*rpmsqAction_t) (int signum);
-#endif
+
+/** \ingroup rpmsq
+ * SIG_DFL, SIG_IGN and SIG_ERR counterparts
+ */
+#define RPMSQ_DFL ((rpmsqAction_t)0)
+#define RPMSQ_IGN ((rpmsqAction_t)1)
+#define RPMSQ_ERR ((rpmsqAction_t)-1)
/** \ingroup rpmsq
* Test if given signal has been caught (while signals blocked).
int rpmsqIsCaught(int signum);
/** \ingroup rpmsq
- * Default signal handler.
+ * Activate (or disable) the signal queue.
+ * @param state 1 to enable, 0 to disable
+ * @return 0 on success, negative on error
+ */
+int rpmsqActivate(int state);
+
+/** \ingroup rpmsq
+ * Set or delete a signal handler for a signal.
* @param signum signal number
- * @param info (siginfo_t) signal info
- * @param context signal context
+ * @param handler signal handler or NULL to delete
+ * @return previous handler, RPMSQ_ERR on error
*/
-#ifdef SA_SIGINFO
-void rpmsqAction(int signum, siginfo_t * info, void * context);
-#else
-void rpmsqAction(int signum);
-#endif
+rpmsqAction_t rpmsqSetAction(int signum, rpmsqAction_t handler);
/** \ingroup rpmsq
- * Enable or disable a signal handler.
- * @param signum signal to enable (or disable if negative)
- * @param handler sa_sigaction handler (or NULL to use rpmsqHandler())
- * @return no. of refs, -1 on error
+ * Block or unblock (almost) all signals.
+ * The operation is "reference counted" so the calls can be nested,
+ * and signals are only unblocked when the reference count falls to zero.
+ * @param op SIG_BLOCK/SIG_UNBLOCK
+ * @return 0 on success, -1 on error
*/
-int rpmsqEnable(int signum, rpmsqAction_t handler);
+int rpmsqBlock(int op);
+
+/** \ingroup rpmsq
+ * Poll for caught signals, executing their handlers.
+ * @return no. active signals found
+ */
+int rpmsqPoll(void);
+
+void rpmsqSetInterruptSafety(int on);
#ifdef __cplusplus
}