I just tried it on linux and the connection is closed even if we don't
request it, I'm not sure how it works on other systems. Regardless, I
think it makes more sense to use posix_spawn_file_actions_* if we're
using posix_spawn, which would look something like this:
---
slock.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/slock.c b/slock.c
index b5a9b04..e77d65c 100644
--- a/slock.c
+++ b/slock.c
@@ -379,11 +379,21 @@ main(int argc, char **argv) {
if (argc > 0) {
pid_t pid;
extern char **environ;
- int err = posix_spawnp(&pid, argv[0], NULL, NULL, argv,
environ);
+ posix_spawn_file_actions_t fa;
+ int err = posix_spawn_file_actions_init(&fa);
+ if (err)
+ goto posix_spawnp_failed;
+
+ err = posix_spawn_file_actions_addclose(&fa,
ConnectionNumber(dpy));
+ if (err)
+ goto posix_spawnp_failed;
+ err = posix_spawnp(&pid, argv[0], &fa, NULL, argv, environ);
if (err) {
+posix_spawnp_failed:
die("slock: failed to execute post-lock command: %s:
%s\n",
argv[0], strerror(err));
}
+ posix_spawn_file_actions_destroy(&fa);
}
/* everything is now blank. Wait for the correct password */
--
2.49.0