Replaced signal masking with signal blocking
This commit is contained in:
parent
1e83bd57c9
commit
e47d1d0b50
36
dwmblocks.c
36
dwmblocks.c
|
@ -29,6 +29,7 @@ typedef struct {
|
|||
|
||||
static void buttonhandler(int signal, siginfo_t *si, void *ucontext);
|
||||
static void getcmd(Block *block, int sigval);
|
||||
static void setroot();
|
||||
static void setupsignals();
|
||||
static void sighandler(int signal, siginfo_t *si, void *ucontext);
|
||||
static void statusloop();
|
||||
|
@ -111,6 +112,17 @@ getcmd(Block *block, int sigval)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
setroot()
|
||||
{
|
||||
if (updatestatus()) {
|
||||
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
|
||||
XStoreName(dpy, DefaultRootWindow(dpy), statusstr);
|
||||
XSync(dpy, False);
|
||||
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
setupsignals()
|
||||
{
|
||||
|
@ -145,7 +157,7 @@ setupsignals()
|
|||
|
||||
/* to handle update signals for individual blocks */
|
||||
sa.sa_flags |= SA_NODEFER;
|
||||
sa.sa_mask = blocksigmask;
|
||||
// sigemptyset(&sa.sa_mask);
|
||||
sa.sa_sigaction = sighandler;
|
||||
for (Block *current = blocks; current->pathu; current++)
|
||||
if (current->signal > 0)
|
||||
|
@ -157,18 +169,18 @@ sighandler(int signal, siginfo_t *si, void *ucontext)
|
|||
{
|
||||
signal -= SIGRTMIN;
|
||||
for (Block *current = blocks; current->pathu; current++)
|
||||
if (current->signal == signal)
|
||||
if (current->signal == signal) {
|
||||
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
|
||||
getcmd(current, si->si_value.sival_int);
|
||||
if (updatestatus()) {
|
||||
XStoreName(dpy, DefaultRootWindow(dpy), statusstr);
|
||||
XSync(dpy, False);
|
||||
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
|
||||
}
|
||||
setroot();
|
||||
}
|
||||
|
||||
void
|
||||
statusloop()
|
||||
{
|
||||
int i = 0;
|
||||
int i;
|
||||
|
||||
/* first run */
|
||||
for (Block *current = blocks; current->pathu; current++)
|
||||
|
@ -177,7 +189,9 @@ statusloop()
|
|||
getcmd(current, NILL);
|
||||
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
|
||||
}
|
||||
goto enterloop;
|
||||
setroot();
|
||||
sleep(SLEEPINTERVAL);
|
||||
i = SLEEPINTERVAL;
|
||||
/* main loop */
|
||||
while (statuscontinue) {
|
||||
for (Block *current = blocks; current->pathu; current++)
|
||||
|
@ -186,13 +200,7 @@ statusloop()
|
|||
getcmd(current, NILL);
|
||||
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
|
||||
}
|
||||
enterloop:
|
||||
if (updatestatus()) {
|
||||
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
|
||||
XStoreName(dpy, DefaultRootWindow(dpy), statusstr);
|
||||
XSync(dpy, False);
|
||||
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
|
||||
}
|
||||
setroot();
|
||||
sleep(SLEEPINTERVAL);
|
||||
i += SLEEPINTERVAL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue