#include <pthread.h>
+#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+/*@unchecked@*/
+static pthread_mutex_t rpmsigTbl_lock = PTHREAD_MUTEX_INITIALIZER;
+#else
/*@unchecked@*/
/*@-type@*/
static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
/*@=type@*/
+#endif
#define DO_LOCK() pthread_mutex_lock(&rpmsigTbl_lock);
#define DO_UNLOCK() pthread_mutex_unlock(&rpmsigTbl_lock);
(void) pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, (__oldtypeptr));\
pthread_cleanup_push((__handler), (__arg));
#define CLEANUP_RESET(__execute, __oldtype) \
- (void) pthread_cleanup_pop(__execute); \
+ pthread_cleanup_pop(__execute); \
(void) pthread_setcanceltype ((__oldtype), &(__oldtype));
#define SAME_THREAD(_a, _b) pthread_equal(((pthread_t)_a), ((pthread_t)_b))
sq->child = 0;
sq->reaped = 0;
sq->status = 0;
- sq->reaper = 1;
+ sq->reaper = 0;
/*@-bounds@*/
sq->pipes[0] = sq->pipes[1] = -1;
/*@=bounds@*/
if (signum >= 0) { /* Enable. */
if (ADD_REF(tbl) <= 0) {
(void) sigdelset(&rpmsqCaught, tbl->signum);
+
+ /* XXX Don't set a signal handler if already SIG_IGN */
+ (void) sigaction(tbl->signum, NULL, &tbl->oact);
+ if (tbl->oact.sa_handler == SIG_IGN)
+ continue;
+
(void) sigemptyset (&sa.sa_mask);
-/*@-compdef -type @*/
sa.sa_flags = SA_SIGINFO;
+#if defined(__LCLINT__) /* XXX glibc has union to track handler prototype. */
+ sa.sa_handler = (handler != NULL ? handler : tbl->handler);
+#else
sa.sa_sigaction = (handler != NULL ? handler : tbl->handler);
+#endif
if (sigaction(tbl->signum, &sa, &tbl->oact) < 0) {
SUB_REF(tbl);
break;
}
-/*@=compdef =type @*/
tbl->active = 1; /* XXX just in case */
if (handler != NULL)
tbl->handler = handler;
sigset_t newMask, oldMask;
rpmsq sq = memset(alloca(sizeof(*sq)), 0, sizeof(*sq));
+#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+ INIT_LOCK ();
+#endif
+
(void) DO_LOCK ();
if (ADD_REF (rpmsigTbl_sigchld) == 0) {
if (rpmsqEnable(SIGINT, NULL) < 0) {