diff options
author | emersion <contact@emersion.fr> | 2018-07-08 22:57:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-08 22:57:06 +0100 |
commit | 6595d07ec7fe4422590fc8f40e35af82518a1c43 (patch) | |
tree | ebcc4bd77c588ba2ce018238ea4a4de3d4659bf2 /swaylock/main.c | |
parent | 57fd65c5b53279abe35c2e446e6770d492dd748d (diff) | |
parent | ceb08b6365d2a085aca5271570c332b3202d305a (diff) |
Merge pull request #2226 from emersion/swaylock-daemonize-after-lock
swaylock: daemonize after locking
Diffstat (limited to 'swaylock/main.c')
-rw-r--r-- | swaylock/main.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/swaylock/main.c b/swaylock/main.c index 1c0cef2b..73c2b5d6 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -38,6 +38,7 @@ static void daemonize() { exit(1); } if (fork() == 0) { + setsid(); close(fds[0]); int devnull = open("/dev/null", O_RDWR); dup2(STDOUT_FILENO, devnull); @@ -406,7 +407,7 @@ int main(int argc, char **argv) { " -v, --version Show the version number and quit.\n" " -i, --image [<output>:]<path> Display the given image.\n" " -u, --no-unlock-indicator Disable the unlock indicator.\n" - " -f, --daemonize Detach from the controlling terminal.\n"; + " -f, --daemonize Detach from the controlling terminal after locking.\n"; state.args = (struct swaylock_args){ .mode = BACKGROUND_MODE_SOLID_COLOR, @@ -454,7 +455,7 @@ int main(int argc, char **argv) { state.args.show_indicator = false; break; case 'f': - daemonize(); + state.args.daemonize = true; break; default: fprintf(stderr, "%s", usage); @@ -510,6 +511,11 @@ int main(int argc, char **argv) { create_layer_surface(surface); } + if (state.args.daemonize) { + wl_display_roundtrip(state.display); + daemonize(); + } + state.run_display = true; while (wl_display_dispatch(state.display) != -1 && state.run_display) { // This space intentionally left blank |