diff options
author | Martin Schwenke <martin@meltin.net> | 2017-08-15 12:53:02 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2017-08-29 11:14:09 +0200 |
commit | 710f5d922ded96f18d475f4143e567997f0d7567 (patch) | |
tree | e51064f1a8d9b5f5f92506cce116ff418d34a3b3 /ctdb/server/ctdb_daemon.c | |
parent | 5f5762d654f85252970ba3a8355908135d90b1d5 (diff) | |
download | samba-710f5d922ded96f18d475f4143e567997f0d7567.tar.gz |
ctdb-daemon: Use become_daemon() instead of custom code
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/server/ctdb_daemon.c')
-rw-r--r-- | ctdb/server/ctdb_daemon.c | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 2ffeae0f968..41f042ecd84 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -34,6 +34,7 @@ #include "lib/util/debug.h" #include "lib/util/time.h" #include "lib/util/blocking.h" +#include "lib/util/become_daemon.h" #include "ctdb_version.h" #include "ctdb_private.h" @@ -1197,20 +1198,8 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork) int res, ret = -1; struct tevent_fd *fde; - if (do_fork && fork()) { - return 0; - } + become_daemon(do_fork, false, false); - if (do_fork) { - if (setsid() == -1) { - ctdb_die(ctdb, "Failed to setsid()\n"); - } - close(0); - if (open("/dev/null", O_RDONLY) != 0) { - DEBUG(DEBUG_ALERT,(__location__ " Failed to setup stdin on /dev/null\n")); - exit(11); - } - } ignore_signal(SIGPIPE); ignore_signal(SIGUSR1); |