From 77d886b04e73d25dbb41af32b0cde39c4b90e18e Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Wed, 26 Jan 2000 21:13:19 +0000 Subject: [PATCH] call ns_os_daemonize() --- bin/named/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bin/named/main.c b/bin/named/main.c index 7ea8d81974..7c015d532c 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -245,6 +245,20 @@ setup() { ns_main_earlyfatal("ns_log_init() failed: %s", isc_result_totext(result)); + /* + * Now is the time to daemonize (if we're not running in the + * foreground). We waited until now because we wanted to get + * a valid logging context setup. We cannot daemonize any later, + * because calling create_managers() will create threads, which + * would be lost after fork(). + */ + if (!ns_g_foreground) { + result = ns_os_daemonize(); + if (result != ISC_R_SUCCESS) + ns_main_earlyfatal("ns_os_daemonize() failed: %s", + isc_result_totext(result)); + } + isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN, ISC_LOG_NOTICE, "starting BIND %s", ns_g_version);