From 20aea1580c678b775c5cc21ffd9e8150583984f0 Mon Sep 17 00:00:00 2001 From: Marius Tolzmann Date: Thu, 19 Nov 2015 15:22:38 +0100 Subject: [PATCH] mx_util: Add wrapper for daemon(3) to prevent nameclashes --- mx_util.c | 5 +++++ mx_util.h | 1 + mxqd.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mx_util.c b/mx_util.c index a78dc6b0..9f2fd57f 100644 --- a/mx_util.c +++ b/mx_util.c @@ -1299,3 +1299,8 @@ int mx_mkdir_p(char *path, mode_t mode) } return (stat(copy, &st) && mkdir(copy, mode)) ? -errno : 0; } + +int mx_daemon(int nochdir, int noclose) +{ + return daemon(nochdir, noclose); +} diff --git a/mx_util.h b/mx_util.h index c67ded7b..f20fe38b 100644 --- a/mx_util.h +++ b/mx_util.h @@ -164,5 +164,6 @@ int mx_str_to_cpuset(cpu_set_t* cpuset_ptr,char *str); int mx_mkdir_p(char *path, mode_t mode); +int mx_daemon(int nochdir, int noclose); #endif diff --git a/mxqd.c b/mxqd.c index d166231a..856197db 100644 --- a/mxqd.c +++ b/mxqd.c @@ -534,7 +534,7 @@ int server_init(struct mxq_server *server, int argc, char *argv[]) } if (arg_daemonize) { - res = daemon(0, 1); + res = mx_daemon(0, 1); if (res == -1) { mx_log_err("MAIN: daemon(0, 1) failed: %m. Exiting."); return -EX_OSERR;