Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Handle SIGUSR1 for forced refreshes
[slstatus.git]
/
slstatus.c
diff --git
a/slstatus.c
b/slstatus.c
index
e6aa90b
..
0806773
100644
(file)
--- a/
slstatus.c
+++ b/
slstatus.c
@@
-18,7
+18,7
@@
struct arg {
};
char buf[1024];
};
char buf[1024];
-static
in
t done;
+static
volatile sig_atomic_
t done;
static Display *dpy;
#include "config.h"
static Display *dpy;
#include "config.h"
@@
-26,9
+26,8
@@
static Display *dpy;
static void
terminate(const int signo)
{
static void
terminate(const int signo)
{
- (void)signo;
-
- done = 1;
+ if (signo != SIGUSR1)
+ done = 1;
}
static void
}
static void
@@
-72,6
+71,8
@@
main(int argc, char *argv[])
act.sa_handler = terminate;
sigaction(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
act.sa_handler = terminate;
sigaction(SIGINT, &act, NULL);
sigaction(SIGTERM, &act, NULL);
+ act.sa_flags |= SA_RESTART;
+ sigaction(SIGUSR1, &act, NULL);
if (!sflag && !(dpy = XOpenDisplay(NULL))) {
die("XOpenDisplay: Failed to open display");
if (!sflag && !(dpy = XOpenDisplay(NULL))) {
die("XOpenDisplay: Failed to open display");
@@
-100,7
+101,8
@@
main(int argc, char *argv[])
if (ferror(stdout))
die("puts:");
} else {
if (ferror(stdout))
die("puts:");
} else {
- if (XStoreName(dpy, DefaultRootWindow(dpy), status) < 0) {
+ if (XStoreName(dpy, DefaultRootWindow(dpy), status)
+ < 0) {
die("XStoreName: Allocation failed");
}
XFlush(dpy);
die("XStoreName: Allocation failed");
}
XFlush(dpy);