Create rpmsq, combining rpmdb/psm signal handlers.
[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  */
8
9 #include <signal.h>
10 #include <sys/signal.h>
11 #include <search.h>
12
13 typedef struct rpmsig_s * rpmsig;
14
15 typedef struct rpmsqElem * rpmsq;
16
17 /**
18  * SIGCHLD queue element.
19  */
20 struct rpmsqElem {
21     struct rpmsqElem * q_forw;  /*!< for use by insque(3)/remque(3). */
22     struct rpmsqElem * q_back;
23     pid_t child;                /*!< Currently running child. */
24     pid_t reaped;               /*!< Reaped waitpid(3) return. */
25     int status;                 /*!< Reaped waitpid(3) status. */
26 };
27
28 /*@unchecked@*/
29 extern rpmsq rpmsqQueue;
30
31 /*@unchecked@*/
32 extern sigset_t rpmsqCaught;
33
34 #ifdef __cplusplus
35 {
36 #endif
37
38 /**
39  */
40 void Insque(/*@null@*/ void * elem, /*@null@*/ void * prev)
41         /*@globals rpmsqQueue @*/
42         /*@modifies elem, rpmsqQueue @*/;
43
44 /**
45  */
46 void Remque(/*@null@*/ void * elem)
47         /*@modifies elem @*/;
48
49 /**
50  */
51 void rpmsqHandler(int signum)
52         /*@globals rpmsqCaught, fileSystem @*/
53         /*@modifies rpmsqCaught, fileSystem @*/;
54
55 /**
56  * Enable or disable a signal handler.
57  * @param signum        signal to enable (or disable if negative)
58  * @param handler       signal handler (or NULL to use rpmsqHandler())
59  * @return              no. of refs, -1 on error
60  */
61 int rpmsqEnable(int signum, /*@null@*/ sighandler_t handler)
62         /*@globals rpmsqCaught, fileSystem, internalState @*/
63         /*@modifies rpmsqCaught, fileSystem, internalState @*/;
64
65 /**
66  * Execute a command, returning its status.
67  */
68 int
69 rpmsqExecve (const char ** argv)
70         /*@*/;
71
72 #ifdef __cplusplus
73 }
74 #endif
75
76 #endif  /* H_RPMSQ */