11 #include <sys/signal.h>
12 #include <search.h> /* XXX insque(3)/remque(3) protos. */
16 typedef struct rpmsig_s * rpmsig;
18 typedef struct rpmsqElem * rpmsq;
20 typedef void (*rpmsqAction_t) (int signum, siginfo_t *info, void *context)
25 extern int _rpmsq_debug;
29 * SIGCHLD queue element.
32 struct rpmsqElem * q_forw; /*!< for use by insque(3)/remque(3). */
33 struct rpmsqElem * q_back;
34 pid_t child; /*!< Currently running child. */
35 volatile pid_t reaped; /*!< Reaped waitpid(3) return. */
36 volatile int status; /*!< Reaped waitpid(3) status. */
37 struct rpmsw_s begin; /*!< Start time. */
38 rpmtime_t msecs; /*!< Instance duration (msecs). */
39 rpmtime_t script_msecs; /*!< Accumulated script duration (msecs). */
40 int reaper; /*!< Register SIGCHLD handler? */
41 int pipes[2]; /*!< Parent/child interlock. */
42 void * id; /*!< Blocking thread id (pthread_t). */
43 pthread_mutex_t mutex; /*!< Signal delivery to thread condvar. */
48 extern rpmsq rpmsqQueue;
51 extern sigset_t rpmsqCaught;
59 int rpmsqInsert(/*@null@*/ void * elem, /*@null@*/ void * prev)
60 /*@globals rpmsqQueue @*/
61 /*@modifies elem, rpmsqQueue @*/;
65 int rpmsqRemove(/*@null@*/ void * elem)
70 void rpmsqAction(int signum, siginfo_t * info, void * context)
71 /*@globals rpmsqCaught, fileSystem @*/
72 /*@modifies rpmsqCaught, fileSystem @*/;
75 * Enable or disable a signal handler.
76 * @param signum signal to enable (or disable if negative)
77 * @param handler sa_sigaction handler (or NULL to use rpmsqHandler())
78 * @return no. of refs, -1 on error
80 int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
81 /*@globals rpmsqCaught, fileSystem, internalState @*/
82 /*@modifies rpmsqCaught, fileSystem, internalState @*/;
85 * Fork a child process.
86 * @param sq scriptlet queue element
89 pid_t rpmsqFork(rpmsq sq)
90 /*@globals fileSystem, internalState @*/
91 /*@modifies sq, fileSystem, internalState @*/;
94 * Wait for child process to be reaped.
95 * @param sq scriptlet queue element
96 * @return reaped child pid
98 pid_t rpmsqWait(rpmsq sq)
99 /*@globals fileSystem, internalState @*/
100 /*@modifies sq, fileSystem, internalState @*/;
103 * Call a function in a thread synchronously.
104 * @param start function
105 * @param arg function argument
106 * @return 0 on success
108 int rpmsqThread(void * (*start) (void * arg), void * arg)
109 /*@globals fileSystem, internalState @*/
110 /*@modifies fileSystem, internalState @*/;
113 * Execute a command, returning its status.
115 int rpmsqExecve (const char ** argv)