Add macro %isu_package to generate ISU Package
[platform/upstream/rpm.git] / rpmio / rpmsq.h
1 #ifndef H_RPMSQ
2 #define H_RPMSQ
3
4 /** \ingroup rpmio
5  * \file rpmio/rpmsq.h
6  *
7  * Signal Queue API
8  */
9 #include <rpm/rpmsw.h>
10 #include <signal.h>
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 /** \ingroup rpmsq
17  * Default signal handler prototype.
18  * @param signum        signal number
19  * @param info          (siginfo_t) signal info
20  * @param context       signal context
21  */
22 typedef void (*rpmsqAction_t) (int signum, siginfo_t * info, void * context);
23
24 /** \ingroup rpmsq
25  *  SIG_DFL, SIG_IGN and SIG_ERR counterparts
26  */
27 #define RPMSQ_DFL       ((rpmsqAction_t)0)
28 #define RPMSQ_IGN       ((rpmsqAction_t)1)
29 #define RPMSQ_ERR       ((rpmsqAction_t)-1)
30
31 /** \ingroup rpmsq
32  * Test if given signal has been caught (while signals blocked).
33  * Similar to sigismember() but operates on internal signal queue.
34  * @param signum        signal to test for
35  * @return              1 if caught, 0 if not and -1 on error
36  */
37 int rpmsqIsCaught(int signum);
38
39 /** \ingroup rpmsq
40  * Activate (or disable) the signal queue.
41  * @param state         1 to enable, 0 to disable
42  * @return              0 on success, negative on error
43  */
44 int rpmsqActivate(int state);
45
46 /** \ingroup rpmsq
47  * Set or delete a signal handler for a signal.
48  * @param signum        signal number
49  * @param handler       signal handler or NULL to delete
50  * @return              previous handler, RPMSQ_ERR on error
51  */
52 rpmsqAction_t rpmsqSetAction(int signum, rpmsqAction_t handler);
53
54 /** \ingroup rpmsq
55  * Block or unblock (almost) all signals.
56  * The operation is "reference counted" so the calls can be nested,
57  * and signals are only unblocked when the reference count falls to zero.
58  * @param op            SIG_BLOCK/SIG_UNBLOCK
59  * @return              0 on success, -1 on error
60  */
61 int rpmsqBlock(int op);
62
63 /** \ingroup rpmsq
64  * Poll for caught signals, executing their handlers.
65  * @return              no. active signals found
66  */
67 int rpmsqPoll(void);
68
69 void rpmsqSetInterruptSafety(int on);
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif  /* H_RPMSQ */