From 1db82b6616f6fdca08be4d9b3a3fc385c97a53eb Mon Sep 17 00:00:00 2001 From: imaginos Date: Mon, 18 Apr 2005 06:11:33 +0000 Subject: [PATCH] use daemon to close fd's and finally daemonize the process git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@149 726aef4b-f618-498e-8847-2d620e286838 --- main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 44057dfa..567000bd 100644 --- a/main.cpp +++ b/main.cpp @@ -177,10 +177,12 @@ int main(int argc, char** argv) { } /* keep the term from hanging on logout */ - close( 0 ); - close( 1 ); - close( 2 ); + if ( daemon( 1, 0 ) != 0 ) { + cerr << "Unable to daemonize!" << endl; + exit( 1 ); + } + #endif struct sigaction sa;