diff options
author | Daiki Ueno <dueno@redhat.com> | 2017-10-05 10:59:02 +0200 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2017-10-05 14:10:51 +0200 |
commit | 031912fa844c4f3da327c8b2578d9d9ce2a6473e (patch) | |
tree | dd2f2e848baacc4c0b3e42a7d84f7b9fc8a9b247 /p11-kit | |
parent | bda61680218a4ff5a9f05b5592bb282cbedfd936 (diff) |
server: Make it possible to eval envvar settings
Previously, calling "eval $(p11-kit server)" from shell hung because
the program didn't properly close stdout before forking.
Diffstat (limited to 'p11-kit')
-rw-r--r-- | p11-kit/server.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/p11-kit/server.c b/p11-kit/server.c index 97e18e2..96c77ec 100644 --- a/p11-kit/server.c +++ b/p11-kit/server.c @@ -346,6 +346,17 @@ server_loop (Server *server, if (server->socket == -1) return 1; + if (!quiet) { + char *path; + + path = p11_path_encode (server->socket_name); + printf ("P11_KIT_SERVER_ADDRESS=unix:path=%s\n", path); + free (path); + printf ("P11_KIT_SERVER_PID=%d\n", getpid ()); + fflush (stdout); + close (STDOUT_FILENO); + } + /* run as daemon */ if (!foreground) { pid = fork (); @@ -372,15 +383,6 @@ server_loop (Server *server, sigprocmask (SIG_BLOCK, &blockset, NULL); - if (!quiet) { - char *path; - - path = p11_path_encode (server->socket_name); - printf ("P11_KIT_SERVER_ADDRESS=unix:path=%s\n", path); - free (path); - printf ("P11_KIT_SERVER_PID=%d\n", getpid ()); - } - /* accept connections */ ret = 0; for (;;) { |