applied andres' multi-slock fix, thanks for spotting this issue - slock - simpl… | |
git clone git://git.suckless.org/slock | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit d276b9b0e01ea086e48ea8327efa0f9ebddca621 | |
parent 4b4fcca1bc3a05e0a4bb5453dfe6dbd84a54b071 | |
Author: [email protected] <unknown> | |
Date: Thu, 2 Aug 2012 21:54:18 +0200 | |
applied andres' multi-slock fix, thanks for spotting this issue | |
Diffstat: | |
M slock.c | 17 ++++++++++++++--- | |
1 file changed, 14 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/slock.c b/slock.c | |
@@ -1,3 +1,4 @@ | |
+ | |
/* See LICENSE file for license details. */ | |
#define _XOPEN_SOURCE 500 | |
#if HAVE_SHADOW_H | |
@@ -211,9 +212,9 @@ lockscreen(Display *dpy, int screen) { | |
break; | |
usleep(1000); | |
} | |
- running = (len > 0); | |
} | |
+ running &= (len > 0); | |
if(!running) { | |
unlockscreen(dpy, lock); | |
lock = NULL; | |
@@ -257,10 +258,20 @@ main(int argc, char **argv) { | |
locks = malloc(sizeof(Lock *) * nscreens); | |
if(locks == NULL) | |
die("slock: malloc: %s", strerror(errno)); | |
- for(screen = 0; screen < nscreens; screen++) | |
- locks[screen] = lockscreen(dpy, screen); | |
+ int nlocks = 0; | |
+ for(screen = 0; screen < nscreens; screen++) { | |
+ if ( (locks[screen] = lockscreen(dpy, screen)) != NULL) | |
+ nlocks++; | |
+ } | |
XSync(dpy, False); | |
+ /* Did we actually manage to lock something? */ | |
+ if (nlocks == 0) { // nothing to protect | |
+ free(locks); | |
+ XCloseDisplay(dpy); | |
+ return 1; | |
+ } | |
+ | |
/* Everything is now blank. Now wait for the correct password. */ | |
#ifdef HAVE_BSD_AUTH | |
readpw(dpy); |