implemented pull request from original project to handle all otherwise unhandled signals, prevents crash
This commit is contained in:
parent
932802d52c
commit
d69593f1cd
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
|||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
|
|
||||||
output: dwmblocks.c blocks.h
|
output: dwmblocks.c config.h
|
||||||
cc `pkg-config --cflags x11` `pkg-config --libs x11` dwmblocks.c -o dwmblocks
|
cc `pkg-config --cflags x11` `pkg-config --libs x11` dwmblocks.c -o dwmblocks
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.gch dwmblocks
|
rm -f *.o *.gch dwmblocks
|
||||||
|
10
config.h
10
config.h
@ -4,19 +4,13 @@ static const Block blocks[] = {
|
|||||||
{"", "music", 3600, 11},
|
{"", "music", 3600, 11},
|
||||||
{"", "getpomminutesft", 100, 3},
|
{"", "getpomminutesft", 100, 3},
|
||||||
{"", "getpomminutes", 100, 3},
|
{"", "getpomminutes", 100, 3},
|
||||||
/* {"", {"weather", 3600, 5},*/
|
/* {"", "weather", 3600, 5},*/
|
||||||
{"", "cpu", 5, 0},
|
{"", "cpu", 5, 0},
|
||||||
/* { "", "sync_status", 4, 0},*/
|
|
||||||
{"", "getmail", 20, 13},
|
{"", "getmail", 20, 13},
|
||||||
/* {"", "btstatus", 2, 17},*/
|
|
||||||
/* {"", "memory", 5, 0},*/
|
|
||||||
{"", "news", 600, 13},
|
{"", "news", 600, 13},
|
||||||
{"", "getbright", 4, 2},
|
{"", "getbright", 4, 2},
|
||||||
{"", "volume", 1, 10},
|
{"", "volume", 1, 10},
|
||||||
/* { "", "amixer get Master | grep -o \"\\(\\[off\\]\\|[0-9]*%\\)\"", 0, 10}*/
|
{"", "clock", 10, 0},
|
||||||
/* {"", "sed \"s/$/%/\" /sys/class/power_supply/BAT?/capacity", 5, 12},*/
|
|
||||||
/* {"", "echo $( battery_dwm BAT0)", 5, 12},*/
|
|
||||||
{"", "clock", 10, 12}, //divert RTMIN update to clock since dwmblocks seems to crash if it's unhandled
|
|
||||||
{"", "internet", 10, 0},
|
{"", "internet", 10, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
22
dwmblocks.c
22
dwmblocks.c
@ -13,7 +13,9 @@ 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 replace(char *str, char old, char new);
|
||||||
void getcmds(int time);
|
void getcmds(int time);
|
||||||
#ifndef __OpenBSD__
|
#ifndef __OpenBSD__
|
||||||
void getsigcmds(int signal);
|
void getsigcmds(int signal);
|
||||||
@ -36,6 +38,14 @@ static char statusstr[2][256];
|
|||||||
static int statusContinue = 1;
|
static int statusContinue = 1;
|
||||||
static void (*writestatus) () = setroot;
|
static void (*writestatus) () = setroot;
|
||||||
|
|
||||||
|
void replace(char *str, char old, char new)
|
||||||
|
{
|
||||||
|
int N = strlen(str);
|
||||||
|
for(int i = 0; i < N; i++)
|
||||||
|
if(str[i] == old)
|
||||||
|
str[i] = new;
|
||||||
|
}
|
||||||
|
|
||||||
//opens process *cmd and stores output in *output
|
//opens process *cmd and stores output in *output
|
||||||
void getcmd(const Block *block, char *output)
|
void getcmd(const Block *block, char *output)
|
||||||
{
|
{
|
||||||
@ -79,6 +89,10 @@ 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)
|
||||||
@ -137,6 +151,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)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user