diff options
Diffstat (limited to 'ntpsnmpd/netsnmp_daemonize.c')
-rw-r--r-- | ntpsnmpd/netsnmp_daemonize.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ntpsnmpd/netsnmp_daemonize.c b/ntpsnmpd/netsnmp_daemonize.c index 43cba8922ca1..969caa0db77a 100644 --- a/ntpsnmpd/netsnmp_daemonize.c +++ b/ntpsnmpd/netsnmp_daemonize.c @@ -191,8 +191,10 @@ int netsnmp_daemonize(int quit_immediately, int stderr_log) { int i = 0; + int saved_errno; + DEBUGMSGT(("daemonize","deamonizing...\n")); -#if HAVE_WORKING_FORK +#ifdef HAVE_WORKING_FORK /* * Fork to return control to the invoking process and to * guarantee that we aren't a process group leader. @@ -200,10 +202,11 @@ netsnmp_daemonize(int quit_immediately, int stderr_log) i = fork(); if (i != 0) { /* Parent. */ + saved_errno = errno; DEBUGMSGT(("daemonize","first fork returned %d.\n", i)); if(i == -1) { snmp_log(LOG_ERR,"first fork failed (errno %d) in " - "netsnmp_daemonize()\n", errno); + "netsnmp_daemonize()\n", saved_errno); return -1; } if (quit_immediately) { @@ -220,10 +223,11 @@ netsnmp_daemonize(int quit_immediately, int stderr_log) * Fork to let the process/session group leader exit. */ if ((i = fork()) != 0) { + saved_errno = errno; DEBUGMSGT(("daemonize","second fork returned %d.\n", i)); if(i == -1) { snmp_log(LOG_ERR,"second fork failed (errno %d) in " - "netsnmp_daemonize()\n", errno); + "netsnmp_daemonize()\n", saved_errno); } /* Parent. */ exit(0); |