Protect sq->reaped with sighold and sigrelease.
[platform/upstream/rpm.git] / rpmio / rpmsq.c
1 /** \ingroup rpmio
2  * \file rpmio/rpmsq.c
3  */
4
5 #include "system.h"
6
7 #if defined(__LCLINT__)
8 #define _BITS_SIGTHREAD_H       /* XXX avoid __sigset_t heartburn. */
9
10 /*@-incondefs -protoparammatch@*/
11 /*@-exportheader@*/
12 /*@constant int SA_SIGINFO@*/
13 extern int sighold(int sig)
14         /*@globals errno, systemState @*/;
15 extern int sigignore(int sig)
16         /*@globals errno, systemState @*/;
17 extern int sigpause(int sig)
18         /*@globals errno, systemState @*/;
19 extern int sigrelse(int sig)
20         /*@globals errno, systemState @*/;
21 extern void (*sigset(int sig, void (*disp)(int)))(int)
22         /*@globals errno, systemState @*/;
23
24 struct qelem;
25 extern  void insque(struct qelem * __elem, struct qelem * __prev)
26         /*@modifies  __elem, __prev @*/;
27 extern  void remque(struct qelem * __elem)
28         /*@modifies  __elem @*/;
29
30 extern pthread_t pthread_self(void)
31         /*@*/;
32 extern int pthread_equal(pthread_t t1, pthread_t t2)
33         /*@*/;
34
35 extern int pthread_create(/*@out@*/ pthread_t *restrict thread,
36                 const pthread_attr_t *restrict attr,
37                 void *(*start_routine)(void*), void *restrict arg)
38         /*@modifies *thread @*/;
39 extern int pthread_join(pthread_t thread, /*@out@*/ void **value_ptr)
40         /*@modifies *value_ptr @*/;
41
42 extern int pthread_setcancelstate(int state, /*@out@*/ int *oldstate)
43         /*@globals internalState @*/
44         /*@modifies *oldstate, internalState @*/;
45 extern int pthread_setcanceltype(int type, /*@out@*/ int *oldtype)
46         /*@globals internalState @*/
47         /*@modifies *oldtype, internalState @*/;
48 extern void pthread_testcancel(void)
49         /*@globals internalState @*/
50         /*@modifies internalState @*/;
51 extern void pthread_cleanup_pop(int execute)
52         /*@globals internalState @*/
53         /*@modifies internalState @*/;
54 extern void pthread_cleanup_push(void (*routine)(void*), void *arg)
55         /*@globals internalState @*/
56         /*@modifies internalState @*/;
57 extern void _pthread_cleanup_pop(/*@out@*/ struct _pthread_cleanup_buffer *__buffer, int execute)
58         /*@globals internalState @*/
59         /*@modifies internalState @*/;
60 extern void _pthread_cleanup_push(/*@out@*/ struct _pthread_cleanup_buffer *__buffer, void (*routine)(void*), /*@out@*/ void *arg)
61         /*@globals internalState @*/
62         /*@modifies internalState @*/;
63
64 extern int pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
65         /*@globals errno, internalState @*/
66         /*@modifies *attr, errno, internalState @*/;
67 extern int pthread_mutexattr_init(/*@out@*/ pthread_mutexattr_t *attr)
68         /*@globals errno, internalState @*/
69         /*@modifies *attr, errno, internalState @*/;
70
71 int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict attr,
72                 /*@out@*/ int *restrict type)
73         /*@modifies *type @*/;
74 int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
75         /*@globals errno, internalState @*/
76         /*@modifies *attr, errno, internalState @*/;
77
78 extern int pthread_mutex_destroy(pthread_mutex_t *mutex)
79         /*@modifies *mutex @*/;
80 extern int pthread_mutex_init(/*@out@*/ pthread_mutex_t *restrict mutex,
81                 /*@null@*/ const pthread_mutexattr_t *restrict attr)
82         /*@globals errno, internalState @*/
83         /*@modifies *mutex, errno, internalState @*/;
84
85 extern int pthread_mutex_lock(pthread_mutex_t *mutex)
86         /*@globals errno @*/
87         /*@modifies *mutex, errno @*/;
88 extern int pthread_mutex_trylock(pthread_mutex_t *mutex)
89         /*@globals errno @*/
90         /*@modifies *mutex, errno @*/;
91 extern int pthread_mutex_unlock(pthread_mutex_t *mutex)
92         /*@globals errno @*/
93         /*@modifies *mutex, errno @*/;
94
95 extern int pthread_cond_destroy(pthread_cond_t *cond)
96         /*@modifies *cond @*/;
97 extern int pthread_cond_init(/*@out@*/ pthread_cond_t *restrict cond,
98                 const pthread_condattr_t *restrict attr)
99         /*@globals errno, internalState @*/
100         /*@modifies *cond, errno, internalState @*/;
101
102 extern int pthread_cond_timedwait(pthread_cond_t *restrict cond,
103                 pthread_mutex_t *restrict mutex,
104                 const struct timespec *restrict abstime)
105         /*@modifies *cond, *mutex @*/;
106 extern int pthread_cond_wait(pthread_cond_t *restrict cond,
107                 pthread_mutex_t *restrict mutex)
108         /*@modifies *cond, *mutex @*/;
109 extern int pthread_cond_broadcast(pthread_cond_t *cond)
110         /*@globals errno, internalState @*/
111         /*@modifies *cond, errno, internalState @*/;
112 extern int pthread_cond_signal(pthread_cond_t *cond)
113         /*@globals errno, internalState @*/
114         /*@modifies *cond, errno, internalState @*/;
115
116 /*@=exportheader@*/
117 /*@=incondefs =protoparammatch@*/
118 #endif
119
120 #include <signal.h>
121 #include <sys/signal.h>
122 #include <sys/wait.h>
123 #include <search.h>
124
125 #if defined(HAVE_PTHREAD_H)
126
127 #include <pthread.h>
128
129 /*@unchecked@*/
130 /*@-type@*/
131 static pthread_mutex_t rpmsigTbl_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
132 /*@=type@*/
133
134 #define DO_LOCK()       pthread_mutex_lock(&rpmsigTbl_lock);
135 #define DO_UNLOCK()     pthread_mutex_unlock(&rpmsigTbl_lock);
136 #define INIT_LOCK()     \
137     {   pthread_mutexattr_t attr; \
138         (void) pthread_mutexattr_init(&attr); \
139         (void) pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
140         (void) pthread_mutex_init (&rpmsigTbl_lock, &attr); \
141         (void) pthread_mutexattr_destroy(&attr); \
142         rpmsigTbl_sigchld->active = 0; \
143     }
144 #define ADD_REF(__tbl)  (__tbl)->active++
145 #define SUB_REF(__tbl)  --(__tbl)->active
146 #define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr) \
147     (void) pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, (__oldtypeptr));\
148         pthread_cleanup_push((__handler), (__arg));
149 #define CLEANUP_RESET(__execute, __oldtype) \
150     (void) pthread_cleanup_pop(__execute); \
151     (void) pthread_setcanceltype ((__oldtype), &(__oldtype));
152
153 #define SAME_THREAD(_a, _b)     pthread_equal(((pthread_t)_a), ((pthread_t)_b))
154
155 #define ME()    ((void *)pthread_self())
156
157 #else
158
159 #define DO_LOCK()
160 #define DO_UNLOCK()
161 #define INIT_LOCK()
162 #define ADD_REF(__tbl)  /*@-noeffect@*/ (0) /*@=noeffect@*/
163 #define SUB_REF(__tbl)  /*@-noeffect@*/ (0) /*@=noeffect@*/
164 #define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr)
165 #define CLEANUP_RESET(__execute, __oldtype)
166
167 #define SAME_THREAD(_a, _b)     (42)
168
169 #define ME()    (((void *)getpid()))
170
171 #endif  /* HAVE_PTHREAD_H */
172
173 #include <rpmsq.h>
174
175 #include "debug.h"
176
177 #define _RPMSQ_DEBUG    0
178 /*@unchecked@*/
179 int _rpmsq_debug = _RPMSQ_DEBUG;
180
181 /*@unchecked@*/
182 static struct rpmsqElem rpmsqRock;
183
184 /*@-compmempass@*/
185 /*@unchecked@*/
186 rpmsq rpmsqQueue = &rpmsqRock;
187 /*@=compmempass@*/
188
189 int rpmsqInsert(void * elem, void * prev)
190 {
191     rpmsq sq = (rpmsq) elem;
192     int ret = -1;
193
194     if (sq != NULL) {
195 #ifdef _RPMSQ_DEBUG
196 if (_rpmsq_debug)
197 fprintf(stderr, "    Insert(%p): %p\n", ME(), sq);
198 #endif
199         ret = sighold(SIGCHLD);
200         if (ret == 0) {
201             sq->child = 0;
202             sq->reaped = 0;
203             sq->status = 0;
204             sq->reaper = 1;
205 /*@-bounds@*/
206             sq->pipes[0] = sq->pipes[1] = -1;
207 /*@=bounds@*/
208
209             sq->id = ME();
210             ret = pthread_mutex_init(&sq->mutex, NULL);
211             ret = pthread_cond_init(&sq->cond, NULL);
212             insque(elem, (prev != NULL ? prev : rpmsqQueue));
213             ret = sigrelse(SIGCHLD);
214         }
215     }
216     return ret;
217 }
218
219 int rpmsqRemove(void * elem)
220 {
221     rpmsq sq = (rpmsq) elem;
222     int ret = -1;
223
224     if (elem != NULL) {
225
226 #ifdef _RPMSQ_DEBUG
227 if (_rpmsq_debug)
228 fprintf(stderr, "    Remove(%p): %p\n", ME(), sq);
229 #endif
230         ret = sighold (SIGCHLD);
231         if (ret == 0) {
232             remque(elem);
233             ret = pthread_cond_destroy(&sq->cond);
234             ret = pthread_mutex_destroy(&sq->mutex);
235             sq->id = NULL;
236 /*@-bounds@*/
237             if (sq->pipes[1])   ret = close(sq->pipes[1]);
238             if (sq->pipes[0])   ret = close(sq->pipes[0]);
239             sq->pipes[0] = sq->pipes[1] = -1;
240 /*@=bounds@*/
241 #ifdef  NOTYET  /* rpmpsmWait debugging message needs */
242             sq->reaper = 1;
243             sq->status = 0;
244             sq->reaped = 0;
245             sq->child = 0;
246 #endif
247             ret = sigrelse(SIGCHLD);
248         }
249     }
250     return ret;
251 }
252
253 /*@unchecked@*/
254 sigset_t rpmsqCaught;
255
256 /*@unchecked@*/
257 /*@-fullinitblock@*/
258 static struct rpmsig_s {
259     int signum;
260     void (*handler) (int signum, void * info, void * context);
261     int active;
262     struct sigaction oact;
263 } rpmsigTbl[] = {
264     { SIGINT,   rpmsqAction },
265 #define rpmsigTbl_sigint        (&rpmsigTbl[0])
266     { SIGQUIT,  rpmsqAction },
267 #define rpmsigTbl_sigquit       (&rpmsigTbl[1])
268     { SIGCHLD,  rpmsqAction },
269 #define rpmsigTbl_sigchld       (&rpmsigTbl[2])
270     { SIGHUP,   rpmsqAction },
271 #define rpmsigTbl_sighup        (&rpmsigTbl[3])
272     { SIGTERM,  rpmsqAction },
273 #define rpmsigTbl_sigterm       (&rpmsigTbl[4])
274     { SIGPIPE,  rpmsqAction },
275 #define rpmsigTbl_sigpipe       (&rpmsigTbl[5])
276     { -1,       NULL },
277 };
278 /*@=fullinitblock@*/
279
280 void rpmsqAction(int signum,
281                 /*@unused@*/ void * info, /*@unused@*/ void * context)
282 {
283     int save = errno;
284     rpmsig tbl;
285
286     for (tbl = rpmsigTbl; tbl->signum >= 0; tbl++) {
287         if (tbl->signum != signum)
288             continue;
289
290         (void) sigaddset(&rpmsqCaught, signum);
291
292         switch (signum) {
293         case SIGCHLD:
294             while (1) {
295                 rpmsq sq;
296                 int status = 0;
297                 pid_t reaped = waitpid(0, &status, WNOHANG);
298
299                 /* XXX errno set to ECHILD/EINVAL/EINTR. */
300                 if (reaped <= 0)
301                     /*@innerbreak@*/ break;
302
303                 /* XXX insque(3)/remque(3) are dequeue, not ring. */
304                 for (sq = rpmsqQueue->q_forw;
305                      sq != NULL && sq != rpmsqQueue;
306                      sq = sq->q_forw)
307                 {
308                     if (sq->child != reaped)
309                         /*@innercontinue@*/ continue;
310                     sq->reaped = reaped;
311                     sq->status = status;
312                     (void) pthread_cond_signal(&sq->cond);
313                     /*@innerbreak@*/ break;
314                 }
315             }
316             /*@switchbreak@*/ break;
317         default:
318             /*@switchbreak@*/ break;
319         }
320         break;
321     }
322     errno = save;
323 }
324
325 int rpmsqEnable(int signum, /*@null@*/ rpmsqAction_t handler)
326         /*@globals rpmsigTbl @*/
327         /*@modifies rpmsigTbl @*/
328 {
329     int tblsignum = (signum >= 0 ? signum : -signum);
330     struct sigaction sa;
331     rpmsig tbl;
332     int ret = -1;
333
334     (void) DO_LOCK ();
335     if (rpmsqQueue->id == NULL)
336         rpmsqQueue->id = ME();
337     for (tbl = rpmsigTbl; tbl->signum >= 0; tbl++) {
338         if (tblsignum != tbl->signum)
339             continue;
340
341         if (signum >= 0) {                      /* Enable. */
342             if (ADD_REF(tbl) <= 0) {
343                 (void) sigdelset(&rpmsqCaught, tbl->signum);
344                 (void) sigemptyset (&sa.sa_mask);
345 /*@-compdef -type @*/
346                 sa.sa_flags = SA_SIGINFO;
347                 sa.sa_sigaction = (handler != NULL ? handler : tbl->handler);
348                 if (sigaction(tbl->signum, &sa, &tbl->oact) < 0) {
349                     SUB_REF(tbl);
350                     break;
351                 }
352 /*@=compdef =type @*/
353                 tbl->active = 1;                /* XXX just in case */
354                 if (handler != NULL)
355                     tbl->handler = handler;
356             }
357         } else {                                /* Disable. */
358             if (SUB_REF(tbl) <= 0) {
359                 if (sigaction(tbl->signum, &tbl->oact, NULL) < 0)
360                     break;
361                 tbl->active = 0;                /* XXX just in case */
362                 tbl->handler = (handler != NULL ? handler : rpmsqAction);
363             }
364         }
365         ret = tbl->active;
366         break;
367     }
368     (void) DO_UNLOCK ();
369     return ret;
370 }
371
372 pid_t rpmsqFork(rpmsq sq)
373 {
374     pid_t pid;
375     int xx;
376
377     if (sq->reaper) {
378         xx = rpmsqInsert(sq, NULL);
379 #ifdef _RPMSQ_DEBUG
380 if (_rpmsq_debug)
381 fprintf(stderr, "    Enable(%p): %p\n", ME(), sq);
382 #endif
383         xx = rpmsqEnable(SIGCHLD, NULL);
384     }
385
386     xx = pipe(sq->pipes);
387
388     xx = sighold(SIGCHLD);
389
390     pid = fork();
391     if (pid < (pid_t) 0) {              /* fork failed.  */
392 /*@-bounds@*/
393         xx = close(sq->pipes[0]);
394         xx = close(sq->pipes[1]);
395         sq->pipes[0] = sq->pipes[1] = -1;
396 /*@=bounds@*/
397         goto out;
398     } else if (pid == (pid_t) 0) {      /* Child. */
399         int yy;
400
401         /* Block to permit parent to wait. */
402 /*@-bounds@*/
403         xx = close(sq->pipes[1]);
404         xx = read(sq->pipes[0], &yy, sizeof(yy));
405         xx = close(sq->pipes[0]);
406         sq->pipes[0] = sq->pipes[1] = -1;
407 /*@=bounds@*/
408
409 #ifdef _RPMSQ_DEBUG
410 if (_rpmsq_debug)
411 fprintf(stderr, "     Child(%p): %p child %d\n", ME(), sq, getpid());
412 #endif
413
414     } else {                            /* Parent. */
415
416         sq->child = pid;
417
418 #ifdef _RPMSQ_DEBUG
419 if (_rpmsq_debug)
420 fprintf(stderr, "    Parent(%p): %p child %d\n", ME(), sq, sq->child);
421 #endif
422
423     }
424
425 out:
426     xx = sigrelse(SIGCHLD);
427     return sq->child;
428 }
429
430 /**
431  * Wait for child process to be reaped, and unregister SIGCHLD handler.
432  * @param sq            scriptlet queue element
433  * @return              0 on success
434  */
435 static int rpmsqWaitUnregister(rpmsq sq)
436         /*@globals fileSystem, internalState @*/
437         /*@modifies sq, fileSystem, internalState @*/
438 {
439     int same_thread = 0;
440     int ret = 0;
441     int xx;
442
443     ret = sighold(SIGCHLD);
444     if (!same_thread)
445         ret = pthread_mutex_lock(&sq->mutex);
446
447     /* Start the child. */
448 /*@-bounds@*/
449     if (sq->pipes[0] >= 0)
450         xx = close(sq->pipes[0]);
451     if (sq->pipes[1] >= 0)
452         xx = close(sq->pipes[1]);
453     sq->pipes[0] = sq->pipes[1] = -1;
454 /*@=bounds@*/
455
456     (void) rpmswEnter(&sq->op, -1);
457
458     /*@-infloops@*/
459     do {
460         if (same_thread)
461             ret = sigpause(SIGCHLD);
462         else {
463             xx = sigrelse(SIGCHLD);
464             ret = pthread_cond_wait(&sq->cond, &sq->mutex);
465             xx = sighold(SIGCHLD);
466         }
467     } while (ret == 0 && sq->reaped != sq->child);
468     /*@=infloops@*/
469
470     sq->ms_scriptlets += rpmswExit(&sq->op, -1)/1000;
471
472     if (!same_thread)
473         xx = pthread_mutex_unlock(&sq->mutex);
474     xx = sigrelse(SIGCHLD);
475
476 #ifdef _RPMSQ_DEBUG
477 if (_rpmsq_debug)
478 fprintf(stderr, "      Wake(%p): %p child %d reaper %d ret %d\n", ME(), sq, sq->child, sq->reaper, ret);
479 #endif
480
481     xx = rpmsqRemove(sq);
482     xx = rpmsqEnable(-SIGCHLD, NULL);
483 #ifdef _RPMSQ_DEBUG
484 if (_rpmsq_debug)
485 fprintf(stderr, "   Disable(%p): %p\n", ME(), sq);
486 #endif
487
488     return ret;
489 }
490
491 pid_t rpmsqWait(rpmsq sq)
492 {
493
494 #ifdef _RPMSQ_DEBUG
495 if (_rpmsq_debug)
496 fprintf(stderr, "      Wait(%p): %p child %d reaper %d\n", ME(), sq, sq->child, sq->reaper);
497 #endif
498
499     if (sq->reaper) {
500         (void) rpmsqWaitUnregister(sq);
501     } else {
502         pid_t reaped;
503         int status;
504         do {
505             reaped = waitpid(sq->child, &status, 0);
506         } while (reaped >= 0 && reaped != sq->child);
507         sq->reaped = reaped;
508         sq->status = status;
509 #ifdef _RPMSQ_DEBUG
510 if (_rpmsq_debug)
511 fprintf(stderr, "   Waitpid(%p): %p child %d reaped %d\n", ME(), sq, sq->child, sq->reaped);
512 #endif
513     }
514
515 #ifdef _RPMSQ_DEBUG
516 if (_rpmsq_debug)
517 fprintf(stderr, "      Fini(%p): %p child %d status 0x%x\n", ME(), sq, sq->child, sq->status);
518 #endif
519
520     return sq->reaped;
521 }
522
523 void * rpmsqThread(void * (*start) (void * arg), void * arg)
524 {
525     pthread_t pth;
526     int ret;
527
528     ret = pthread_create(&pth, NULL, start, arg);
529     return (ret == 0 ? (void *)pth : NULL);
530 }
531
532 int rpmsqJoin(void * thread)
533 {
534     pthread_t pth = (pthread_t) thread;
535     if (thread == NULL)
536         return EINVAL;
537     return pthread_join(pth, NULL);
538 }
539
540 int rpmsqThreadEqual(void * thread)
541 {
542     pthread_t t1 = (pthread_t) thread;
543     pthread_t t2 = pthread_self();
544     return pthread_equal(t1, t2);
545 }
546
547 /**
548  * SIGCHLD cancellation handler.
549  */
550 static void
551 sigchld_cancel (void *arg)
552         /*@globals rpmsigTbl, fileSystem, internalState @*/
553         /*@modifies rpmsigTbl, fileSystem, internalState @*/
554 {
555     pid_t child = *(pid_t *) arg;
556     pid_t result;
557
558     (void) kill(child, SIGKILL);
559
560     do {
561         result = waitpid(child, NULL, 0);
562     } while (result == (pid_t)-1 && errno == EINTR);
563
564     (void) DO_LOCK ();
565     if (SUB_REF (rpmsigTbl_sigchld) == 0) {
566         (void) rpmsqEnable(-SIGQUIT, NULL);
567         (void) rpmsqEnable(-SIGINT, NULL);
568     }
569     (void) DO_UNLOCK ();
570 }
571
572 /**
573  * Execute a command, returning its status.
574  */
575 int
576 rpmsqExecve (const char ** argv)
577         /*@globals rpmsigTbl @*/
578         /*@modifies rpmsigTbl @*/
579 {
580     int oldtype;
581     int status = -1;
582     pid_t pid = 0;
583     pid_t result;
584     sigset_t newMask, oldMask;
585     rpmsq sq = memset(alloca(sizeof(*sq)), 0, sizeof(*sq));
586
587     (void) DO_LOCK ();
588     if (ADD_REF (rpmsigTbl_sigchld) == 0) {
589         if (rpmsqEnable(SIGINT, NULL) < 0) {
590             SUB_REF (rpmsigTbl_sigchld);
591             goto out;
592         }
593         if (rpmsqEnable(SIGQUIT, NULL) < 0) {
594             SUB_REF (rpmsigTbl_sigchld);
595             goto out_restore_sigint;
596         }
597     }
598     (void) DO_UNLOCK ();
599
600     (void) sigemptyset (&newMask);
601     (void) sigaddset (&newMask, SIGCHLD);
602     if (sigprocmask (SIG_BLOCK, &newMask, &oldMask) < 0) {
603         (void) DO_LOCK ();
604         if (SUB_REF (rpmsigTbl_sigchld) == 0)
605             goto out_restore_sigquit_and_sigint;
606         goto out;
607     }
608
609     CLEANUP_HANDLER(sigchld_cancel, &pid, &oldtype);
610
611     pid = fork ();
612     if (pid < (pid_t) 0) {              /* fork failed.  */
613         goto out;
614     } else if (pid == (pid_t) 0) {      /* Child. */
615
616         /* Restore the signals.  */
617         (void) sigaction (SIGINT, &rpmsigTbl_sigint->oact, NULL);
618         (void) sigaction (SIGQUIT, &rpmsigTbl_sigquit->oact, NULL);
619         (void) sigprocmask (SIG_SETMASK, &oldMask, NULL);
620
621         /* Reset rpmsigTbl lock and refcnt. */
622         INIT_LOCK ();
623
624         (void) execve (argv[0], (char *const *) argv, environ);
625         _exit (127);
626     } else {                            /* Parent. */
627         do {
628             result = waitpid(pid, &status, 0);
629         } while (result == (pid_t)-1 && errno == EINTR);
630         if (result != pid)
631             status = -1;
632     }
633
634     CLEANUP_RESET(0, oldtype);
635
636     (void) DO_LOCK ();
637     if ((SUB_REF (rpmsigTbl_sigchld) == 0 &&
638         (rpmsqEnable(-SIGINT, NULL) < 0 || rpmsqEnable (-SIGQUIT, NULL) < 0))
639       || sigprocmask (SIG_SETMASK, &oldMask, NULL) != 0)
640     {
641         status = -1;
642     }
643     goto out;
644
645 out_restore_sigquit_and_sigint:
646     (void) rpmsqEnable(-SIGQUIT, NULL);
647 out_restore_sigint:
648     (void) rpmsqEnable(-SIGINT, NULL);
649 out:
650     (void) DO_UNLOCK ();
651     return status;
652 }