This no longer closes the connection to the X server before executing
the post-lock cmd. This patch should fix that, but doesn't die if
fcntl() fails, I'm not sure if that's desired.
---
slock.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/slock.c b/slock.c
index b5a9b04..856c3e6 100644
--- a/slock.c
+++ b/slock.c
@@ -6,6 +6,7 @@
#include <ctype.h>
#include <errno.h>
+#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <stdarg.h>
@@ -59,7 +60,6 @@ die(const char *errstr, ...)
}
#ifdef __linux__
-#include <fcntl.h>
#include <linux/oom.h>
static void
@@ -379,6 +379,10 @@ main(int argc, char **argv) {
if (argc > 0) {
pid_t pid;
extern char **environ;
+ int xfd = ConnectionNumber(dpy);
+ int flags = fcntl(xfd, F_GETFD);
+ if (flags >= 0)
+ fcntl(xfd, F_SETFD, flags | FD_CLOEXEC);
int err = posix_spawnp(&pid, argv[0], NULL, NULL, argv,
environ);
if (err) {
die("slock: failed to execute post-lock command: %s:
%s\n",
--
2.49.0