aboutsummaryrefslogtreecommitdiffstats
path: root/src/satd.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-28 15:10:13 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-28 15:10:13 +0100
commitd122f3dc648f92568d481734bccff30a362047ae (patch)
tree6da50cc6699dd9785ca18e668bd990a57a3bc869 /src/satd.c
parentreorder actions (diff)
downloadsat-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.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/satd.c b/src/satd.c
index ed5d07a..1bfb829 100644
--- a/src/satd.c
+++ b/src/satd.c
@@ -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();