rpm  5.4.14
Data Structures | Macros | Functions | Variables
#include "system.h"
#include <signal.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <search.h>
#include <rpmsq.h>
#include "debug.h"
Include dependency graph for rpmsq.c:

Go to the source code of this file.

Data Structures

struct  rpmsig_s
 

Macros

#define DO_LOCK()   (0)
 
#define DO_UNLOCK()   (0)
 
#define INIT_LOCK()
 
#define ADD_REF(__tbl)   /*@-noeffect@*/ (0) /*@=noeffect@*/
 
#define SUB_REF(__tbl)   /*@-noeffect@*/ (0) /*@=noeffect@*/
 
#define CLEANUP_HANDLER(__handler, __arg, __oldtypeptr)
 
#define CLEANUP_RESET(__execute, __oldtype)
 
#define SAME_THREAD(_a, _b)   (42)
 
#define ME()   __pid2vp(getpid())
 
#define _RPMSQ_INTERNAL
 
#define _RPMSQ_DEBUG   0
 
#define rpmsigTbl_sigint   (&rpmsigTbl[0])
 
#define rpmsigTbl_sigquit   (&rpmsigTbl[1])
 
#define rpmsigTbl_sigchld   (&rpmsigTbl[2])
 
#define rpmsigTbl_sighup   (&rpmsigTbl[3]) /* XXX unused */
 
#define rpmsigTbl_sigterm   (&rpmsigTbl[4]) /* XXX unused */
 
#define rpmsigTbl_sigpipe   (&rpmsigTbl[5]) /* XXX unused */
 

Functions

static void__pid2vp (pid_t pid)
 
int rpmsqInsert (void *elem, void *prev)
 Insert node into from queue. More...
 
int rpmsqRemove (void *elem)
 Remove node from queue. More...
 
void rpmsqAction (int signum, void *info, void *context)
 Default signal handler. More...
 
int rpmsqEnable (int signum, rpmsqAction_t handler)
 Enable or disable a signal handler. More...
 
pid_t rpmsqFork (rpmsq sq)
 Fork a child process. More...
 
static int rpmsqWaitUnregister (rpmsq sq)
 Wait for child process to be reaped, and unregister SIGCHLD handler. More...
 
pid_t rpmsqWait (rpmsq sq)
 Wait for child process to be reaped. More...
 
voidrpmsqThread (void *(*start)(void *arg), void *arg)
 Call a function in a thread. More...
 
int rpmsqJoin (void *thread)
 Wait for thread to terminate. More...
 
int rpmsqThreadEqual (void *thread)
 Compare thread with current thread. More...
 
 if ((0)==0)
 
 if (sigprocmask(SIG_BLOCK,&newMask,&oldMask)< 0)
 
else if (pid==(pid_t) 0)
 
 if (((0)==0 &&(rpmsqEnable(-SIGINT, NULL)< 0||rpmsqEnable(-SIGQUIT, NULL)< 0))||sigprocmask(SIG_SETMASK,&oldMask, NULL)!=0)
 

Variables

int _rpmsq_debug = 0
 
static struct rpmsqElem rpmsqRock = { &rpmsqRock, NULL }
 
rpmsq rpmsqQueue = &rpmsqRock
 
sigset_t rpmsqCaught
 
static struct rpmsig_s rpmsigTbl []
 
 int
 SIGCHLD cancellation handler. More...
 
pid_t pid = 0
 
sigset_t newMask
 
sigset_t oldMask
 
rpmsq sq = (rpmsq) memset(alloca(sizeof(*sq)), 0, sizeof(*sq))
 
int xx = (0)
 
 else
 
 status = -1
 
goto out
 
out_restore_sigquit_and_sigint __pad0__
 
out_restore_sigquit_and_sigint NULL
 
out_restore_sigint __pad1__
 
out __pad2__
 
Class: Rpmspec
pid_t result = NULL
 

Macro Definition Documentation

#define _RPMSQ_DEBUG   0

Definition at line 276 of file rpmsq.c.

#define _RPMSQ_INTERNAL

Definition at line 271 of file rpmsq.c.

#define ADD_REF (   __tbl)    /*@-noeffect@*/ (0) /*@=noeffect@*/

Definition at line 251 of file rpmsq.c.

Referenced by rpmsqEnable().

#define CLEANUP_HANDLER (   __handler,
  __arg,
  __oldtypeptr 
)

Definition at line 253 of file rpmsq.c.

#define CLEANUP_RESET (   __execute,
  __oldtype 
)

Definition at line 254 of file rpmsq.c.

#define DO_LOCK ( )    (0)

Definition at line 248 of file rpmsq.c.

Referenced by if(), and rpmsqEnable().

#define DO_UNLOCK ( )    (0)

Definition at line 249 of file rpmsq.c.

Referenced by rpmsqEnable().

#define INIT_LOCK ( )

Definition at line 250 of file rpmsq.c.

#define ME ( )    __pid2vp(getpid())
#define rpmsigTbl_sigchld   (&rpmsigTbl[2])

Referenced by if().

#define rpmsigTbl_sighup   (&rpmsigTbl[3]) /* XXX unused */
#define rpmsigTbl_sigint   (&rpmsigTbl[0])
#define rpmsigTbl_sigpipe   (&rpmsigTbl[5]) /* XXX unused */
#define rpmsigTbl_sigquit   (&rpmsigTbl[1])
#define rpmsigTbl_sigterm   (&rpmsigTbl[4]) /* XXX unused */
#define SAME_THREAD (   _a,
  _b 
)    (42)

Definition at line 256 of file rpmsq.c.

#define SUB_REF (   __tbl)    /*@-noeffect@*/ (0) /*@=noeffect@*/

Definition at line 252 of file rpmsq.c.

Referenced by if(), and rpmsqEnable().

Function Documentation

static void* __pid2vp ( pid_t  pid)
static

Definition at line 261 of file rpmsq.c.

References pid, and u.

if ( (0)  = = 0)

Definition at line 747 of file rpmsq.c.

References NULL, out, rpmsigTbl_sigchld, rpmsqEnable(), and SUB_REF.

if ( )

Definition at line 761 of file rpmsq.c.

References DO_LOCK, out, rpmsigTbl_sigchld, and SUB_REF.

else if ( pid  = = (pid_t) 0)

Definition at line 775 of file rpmsq.c.

if ( ((0)==0 &&(rpmsqEnable(-SIGINT, NULL)< 0||rpmsqEnable(-SIGQUIT, NULL)< 0))||sigprocmask(SIG_SETMASK,&oldMask, NULL)!  = 0)

Definition at line 798 of file rpmsq.c.

void rpmsqAction ( int  signum,
void info,
void context 
)

Default signal handler.

Parameters
signumsignal number
info(siginfo_t) signal info
contextsignal context

Definition at line 390 of file rpmsq.c.

References errno, NULL, ret, rpmsigTbl, rpmsig_s::signum, sq, status, and void.

Referenced by rpmsqEnable().

int rpmsqEnable ( int  signum,
rpmsqAction_t  handler 
)

Enable or disable a signal handler.

Parameters
signumsignal to enable (or disable if negative)
handlersa_sigaction handler (or NULL to use rpmsqHandler())
Returns
no. of refs, -1 on error

Definition at line 439 of file rpmsq.c.

References ADD_REF, DO_LOCK, DO_UNLOCK, int, ME, NULL, ret, rpmsigTbl, rpmsqAction(), rpmsig_s::signum, SUB_REF, void, and xx.

Referenced by if(), rpmdbClose(), rpmdbOpenDatabase(), rpmsqFork(), and rpmsqWaitUnregister().

pid_t rpmsqFork ( rpmsq  sq)

Fork a child process.

Parameters
sqscriptlet queue element
Returns
fork(2) pid

Definition at line 495 of file rpmsq.c.

References fprintf(), int, ME, NULL, out, pid, rpmsqEnable(), rpmsqInsert(), and xx.

Referenced by runScript().

int rpmsqInsert ( void elem,
void prev 
)

Insert node into from queue.

Parameters
elemnode to link
prevprevious node from queue
Returns
0 on success

Definition at line 291 of file rpmsq.c.

References fprintf(), ME, NULL, ret, and sq.

Referenced by rpmsqFork().

int rpmsqJoin ( void thread)

Wait for thread to terminate.

Parameters
threadthread
Returns
0 on success

Definition at line 671 of file rpmsq.c.

References NULL, and void.

Referenced by fsmNext(), iosmNext(), and rpmpsmNext().

int rpmsqRemove ( void elem)

Remove node from queue.

Parameters
elemnode to link
Returns
0 on success

Definition at line 320 of file rpmsq.c.

References fprintf(), ME, NULL, ret, and sq.

Referenced by rpmsqWaitUnregister().

void* rpmsqThread ( void *(*)(void *arg)  start,
void arg 
)

Call a function in a thread.

Parameters
startfunction
argfunction argument
Returns
thread pointer (NULL on error)

Definition at line 656 of file rpmsq.c.

References NULL, ret, and void.

Referenced by fsmNext(), iosmNext(), and rpmpsmNext().

int rpmsqThreadEqual ( void thread)

Compare thread with current thread.

Parameters
threadthread
Returns
0 if not equal

Definition at line 684 of file rpmsq.c.

References void.

pid_t rpmsqWait ( rpmsq  sq)

Wait for child process to be reaped.

Parameters
sqscriptlet queue element
Returns
reaped child pid

Definition at line 624 of file rpmsq.c.

References fprintf(), ME, rpmsqWaitUnregister(), status, and void.

Referenced by psmWait().

static int rpmsqWaitUnregister ( rpmsq  sq)
static

Wait for child process to be reaped, and unregister SIGCHLD handler.

Todo:
Rewrite to use waitpid on helper thread.
Parameters
sqscriptlet queue element
Returns
0 on success

Definition at line 557 of file rpmsq.c.

References assert(), fprintf(), ME, NULL, ret, rpmsqEnable(), rpmsqRemove(), rpmswEnter(), rpmswExit(), void, and xx.

Referenced by rpmsqWait().

Variable Documentation

out_restore_sigquit_and_sigint __pad0__

Definition at line 807 of file rpmsq.c.

out_restore_sigint __pad1__

Definition at line 809 of file rpmsq.c.

out __pad2__

Definition at line 811 of file rpmsq.c.

int _rpmsq_debug = 0

Definition at line 278 of file rpmsq.c.

else
Initial value:
{
do {
result = waitpid(pid, &status, 0);
} while (result == (pid_t)-1 && errno == EINTR)
pid_t pid
Definition: rpmsq.c:736
int errno
pid_t result
Definition: rpmsq.c:737
status
Definition: rpmsq.c:792

Definition at line 787 of file rpmsq.c.

int
Initial value:
{
int status = -1
status
Definition: rpmsq.c:792

SIGCHLD cancellation handler.

Execute a command, returning its status.

Definition at line 731 of file rpmsq.c.

void sigaddset & newMask

Definition at line 738 of file rpmsq.c.

Referenced by blockSignals(), rpmdbCheckTerminate(), and signalsCaught().

out_restore_sigint NULL

Definition at line 807 of file rpmsq.c.

sigset_t oldMask

Definition at line 738 of file rpmsq.c.

Referenced by rpmdbCheckTerminate(), and signalsCaught().

goto out

Definition at line 804 of file rpmsq.c.

Referenced by addChangelog(), if(), rpmsqFork(), runScript(), and Symlink().

pid = 0
return result = NULL
struct rpmsig_s rpmsigTbl[]
static
Initial value:
= {
{ SIGINT, rpmsqAction },
#define rpmsigTbl_sigint
{ SIGQUIT, rpmsqAction },
#define rpmsigTbl_sigquit
{ SIGCHLD, rpmsqAction },
#define rpmsigTbl_sigchld
{ SIGHUP, rpmsqAction },
#define rpmsigTbl_sighup
{ SIGTERM, rpmsqAction },
#define rpmsigTbl_sigterm
{ SIGPIPE, rpmsqAction },
#define rpmsigTbl_sigpipe
{ -1, NULL },
}
void rpmsqAction(int signum, void *info, void *context)
Default signal handler.
Definition: rpmsq.c:390
return NULL
Definition: poptALL.c:613

Referenced by rpmsqAction(), and rpmsqEnable().

sigset_t rpmsqCaught

Definition at line 352 of file rpmsq.c.

Referenced by rpmdbCheckSignals(), rpmdbCheckTerminate(), and signalsCaught().

rpmsq rpmsqQueue = &rpmsqRock

Definition at line 288 of file rpmsq.c.

struct rpmsqElem rpmsqRock = { &rpmsqRock, NULL }
static

Definition at line 283 of file rpmsq.c.

rpmsq sq = (rpmsq) memset(alloca(sizeof(*sq)), 0, sizeof(*sq))

Definition at line 739 of file rpmsq.c.

Referenced by rpmsqAction(), rpmsqInsert(), and rpmsqRemove().

return status = -1
xx = (0)

Definition at line 740 of file rpmsq.c.