[Git][NTPsec/ntpsec][master] Logging properly switches over to file on daemonization.

Ian Bruene gitlab at mg.gitlab.com
Tue Mar 6 22:22:32 UTC 2018


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
d665cf33 by Ian Bruene at 2018-03-06T22:20:39Z
Logging properly switches over to file on daemonization.

- - - - -


1 changed file:

- ntpclients/ntpsnmpd.py


Changes:

=====================================
ntpclients/ntpsnmpd.py
=====================================
--- a/ntpclients/ntpsnmpd.py
+++ b/ntpclients/ntpsnmpd.py
@@ -1171,14 +1171,22 @@ def daemonize(runfunc, *runArgs):
 
     # chdir should be here, change to what? root?
 
+    global logfp
+    if logfp == sys.stderr:
+        logfp = None
+
     sys.stdin.close()
+    sys.stdin = None
     sys.stdout.close()
+    sys.stdout = None
     sys.stderr.close()
+    sys.stderr = None
 
     runfunc(*runArgs)
 
 
 def loadSettings(filename, optionList):
+    log("Loading config file: %s\n" % filename, 3)
     if os.path.isfile(filename) is False:
         return None
     options = {}
@@ -1295,6 +1303,9 @@ if __name__ == "__main__":
             logfile = val
             fileLogging = True
 
+    if nofork is False:
+        fileLogging = True
+
     if fileLogging is True:
         if logfp != sys.stderr:
             logfp.close()



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d665cf339368e8161234244e23d00cd326a8669e

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d665cf339368e8161234244e23d00cd326a8669e
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180306/efaac3bc/attachment.html>


More information about the vc mailing list