Merge pull request #8 from markcaudill/master

This merge adds fix for issue #5 which @markcaudill fixed by having all real-time signals handled by a dummy handler if it doesn't have a refresh signal .
This commit is contained in:
torrinfail 2020-06-11 01:13:49 -06:00 committed by GitHub
commit 31b9d65b31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -13,6 +13,7 @@ typedef struct {
unsigned int interval; unsigned int interval;
unsigned int signal; unsigned int signal;
} Block; } Block;
void dummysighandler(int num);
void sighandler(int num); void sighandler(int num);
void getcmds(int time); void getcmds(int time);
#ifndef __OpenBSD__ #ifndef __OpenBSD__
@ -58,7 +59,7 @@ void getcmds(int time)
{ {
const Block* current; const Block* current;
for(int i = 0; i < LENGTH(blocks); i++) for(int i = 0; i < LENGTH(blocks); i++)
{ {
current = blocks + i; current = blocks + i;
if ((current->interval != 0 && time % current->interval == 0) || time == -1) if ((current->interval != 0 && time % current->interval == 0) || time == -1)
getcmd(current,statusbar[i]); getcmd(current,statusbar[i]);
@ -79,8 +80,12 @@ void getsigcmds(int signal)
void setupsignals() void setupsignals()
{ {
/* initialize all real time signals with dummy handler */
for(int i = SIGRTMIN; i <= SIGRTMAX; i++)
signal(i, dummysighandler);
for(int i = 0; i < LENGTH(blocks); i++) for(int i = 0; i < LENGTH(blocks); i++)
{ {
if (blocks[i].signal > 0) if (blocks[i].signal > 0)
signal(SIGRTMIN+blocks[i].signal, sighandler); signal(SIGRTMIN+blocks[i].signal, sighandler);
} }
@ -137,6 +142,14 @@ void statusloop()
} }
} }
#ifndef __OpenBSD__
/* this signal handler should do nothing */
void dummysighandler(int signum)
{
return;
}
#endif
#ifndef __OpenBSD__ #ifndef __OpenBSD__
void sighandler(int signum) void sighandler(int signum)
{ {
@ -154,7 +167,7 @@ void termhandler(int signum)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
for(int i = 0; i < argc; i++) for(int i = 0; i < argc; i++)
{ {
if (!strcmp("-d",argv[i])) if (!strcmp("-d",argv[i]))
delim = argv[++i][0]; delim = argv[++i][0];
else if(!strcmp("-p",argv[i])) else if(!strcmp("-p",argv[i]))