diff options
author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-28 15:10:13 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-28 15:10:13 +0100 |
commit | d122f3dc648f92568d481734bccff30a362047ae (patch) | |
tree | 6da50cc6699dd9785ca18e668bd990a57a3bc869 /src/satd.c | |
parent | reorder actions (diff) | |
download | sat-d122f3dc648f92568d481734bccff30a362047ae.tar.gz sat-d122f3dc648f92568d481734bccff30a362047ae.tar.bz2 sat-d122f3dc648f92568d481734bccff30a362047ae.tar.xz |
update daemonise, and daemonise when fully initialised
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'src/satd.c')
-rw-r--r-- | src/satd.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -196,9 +196,6 @@ main(int argc, char *argv[]) else if ((path = getenv("SATD_SOCKET_PATH"))) have_socket = S_ISSOCK(attr.st_mode); - /* Daemonise. */ - t (foreground ? 0 : daemonise("satd", have_socket ? DAEMONISE_KEEP_STDIN : 0)); - /* Get or create socket. */ if (have_socket) { if (strlen(path) >= sizeof(address.sun_path)) @@ -232,6 +229,13 @@ main(int argc, char *argv[]) t (listen(sock, SATD_BACKLOG)); #endif + /* Daemonise. */ + if (!foreground) { + int flags = have_socket ? DAEMONISE_KEEP_STDIN : 0; + flags |= DAEMONISE_KEEP_FDS; + t (daemonise("satd", flags, sock, -1)); + } + close(sock); unlink(address.sun_path); undaemonise(); |