Re: [hackers] [slstatus][PATCH] Handle SIGUSR1 for forced refreshes
Merged. Thanks! On 20-06-18 Thu, Mart Lubbers wrote: At some point one might want to force a refresh for example after checking email or changing the volume. Sending a SIGUSR1 achieves this now --- slstatus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slstatus.c b/slstatus.c index 96fa5b6..499cd30 100644 --- a/slstatus.c +++ b/slstatus.c @@ -26,9 +26,8 @@ static Display *dpy; static void terminate(const int signo) { - (void)signo; - - done = 1; + if (signo != SIGUSR1) + done = 1; } static void @@ -72,6 +71,7 @@ main(int argc, char *argv[]) act.sa_handler = terminate; sigaction(SIGINT, , NULL); sigaction(SIGTERM, , NULL); + sigaction(SIGUSR1, , NULL); if (!sflag && !(dpy = XOpenDisplay(NULL))) { die("XOpenDisplay: Failed to open display"); -- 2.20.1 -- Web: https://drkhsh.at/ or http://drkhsh5rv6pnahas.onion/ GPG: 0x7A65E38D55BE96FE Fingerprint: 4688 907C 8720 3318 0D9F AFDE 7A65 E38D 55BE 96FE
Re: [hackers] [slstatus][PATCH] Handle SIGUSR1 for forced refreshes
At some point one might want to force a refresh for example after checking email or changing the volume. Sending a SIGUSR1 achieves this now. --- slstatus.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/slstatus.c b/slstatus.c index 96fa5b6..ee42786 100644 --- a/slstatus.c +++ b/slstatus.c @@ -18,7 +18,7 @@ struct arg { }; char buf[1024]; -static int done; +static volatile sig_atomic_t done; static Display *dpy; #include "config.h" @@ -26,9 +26,9 @@ static Display *dpy; static void terminate(const int signo) { - (void)signo; - - done = 1; + if (signo != SIGUSR1) { + done = 1; + } } static void @@ -72,6 +72,8 @@ main(int argc, char *argv[]) act.sa_handler = terminate; sigaction(SIGINT, , NULL); sigaction(SIGTERM, , NULL); + act.sa_flags |= SA_RESTART; + sigaction(SIGUSR1, , NULL); if (!sflag && !(dpy = XOpenDisplay(NULL))) { die("XOpenDisplay: Failed to open display"); -- 2.20.1 signature.asc Description: PGP signature
Re: [hackers] [slstatus][PATCH] Handle SIGUSR1 for forced refreshes
On Tue, Jul 14, 2020 at 02:45:14PM +0200, Mart Lubbers wrote: > Dear all, > I've submitted this patch before but maybe I did something wrong (it was > before > the confirmation mail of the subscription). If there is anything else off with > this email/patch, please let me know. > Best, > > Original email: > > At some point one might want to force a refresh for example after > checking email or changing the volume. Sending a SIGUSR1 achieves this > now > > --- > slstatus.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/slstatus.c b/slstatus.c > index 96fa5b6..499cd30 100644 > --- a/slstatus.c > +++ b/slstatus.c > @@ -26,9 +26,8 @@ static Display *dpy; > static void > terminate(const int signo) > { > - (void)signo; > - > - done = 1; > + if (signo != SIGUSR1) > + done = 1; > } > > static void > @@ -72,6 +71,7 @@ main(int argc, char *argv[]) > act.sa_handler = terminate; > sigaction(SIGINT, , NULL); > sigaction(SIGTERM, , NULL); > + sigaction(SIGUSR1, , NULL); > > if (!sflag && !(dpy = XOpenDisplay(NULL))) { > die("XOpenDisplay: Failed to open display"); > -- > 2.20.1 Hi, It sounds useful to me. Handling SIGUSR1 probably increases the change of some race-condition though (SIGINT and SIGTERM ends the program so it doesn't matter much). Maybe setting sigaction.sa_flags to SA_RESTART helps a bit to atleast avoid EINTR in some calls (like stdio file write/reads)? And a nitpick (probably does not matter in practise) but maybe done should be of the type volatile sig_atomic_t? -- Kind regards, Hiltjo signature.asc Description: PGP signature
[hackers] [slstatus][PATCH] Handle SIGUSR1 for forced refreshes
Dear all, I've submitted this patch before but maybe I did something wrong (it was before the confirmation mail of the subscription). If there is anything else off with this email/patch, please let me know. Best, Original email: At some point one might want to force a refresh for example after checking email or changing the volume. Sending a SIGUSR1 achieves this now --- slstatus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slstatus.c b/slstatus.c index 96fa5b6..499cd30 100644 --- a/slstatus.c +++ b/slstatus.c @@ -26,9 +26,8 @@ static Display *dpy; static void terminate(const int signo) { - (void)signo; - - done = 1; + if (signo != SIGUSR1) + done = 1; } static void @@ -72,6 +71,7 @@ main(int argc, char *argv[]) act.sa_handler = terminate; sigaction(SIGINT, , NULL); sigaction(SIGTERM, , NULL); + sigaction(SIGUSR1, , NULL); if (!sflag && !(dpy = XOpenDisplay(NULL))) { die("XOpenDisplay: Failed to open display"); -- 2.20.1 signature.asc Description: PGP signature
[hackers] [slstatus][PATCH] Handle SIGUSR1 for forced refreshes
At some point one might want to force a refresh for example after checking email or changing the volume. Sending a SIGUSR1 achieves this now --- slstatus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/slstatus.c b/slstatus.c index 96fa5b6..499cd30 100644 --- a/slstatus.c +++ b/slstatus.c @@ -26,9 +26,8 @@ static Display *dpy; static void terminate(const int signo) { - (void)signo; - - done = 1; + if (signo != SIGUSR1) + done = 1; } static void @@ -72,6 +71,7 @@ main(int argc, char *argv[]) act.sa_handler = terminate; sigaction(SIGINT, , NULL); sigaction(SIGTERM, , NULL); + sigaction(SIGUSR1, , NULL); if (!sflag && !(dpy = XOpenDisplay(NULL))) { die("XOpenDisplay: Failed to open display"); -- 2.20.1 signature.asc Description: PGP signature