commit: 10a308cef6fecb1d8e3b4ffd932f79d5020bec85
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 2 22:32:51 2015 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Jul 2 22:32:51 2015 +0000
URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=10a308ce
Daemon.py: add kudos.
grs/Daemon.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/grs/Daemon.py b/grs/Daemon.py
index 8fed2a1..15290a5 100644
--- a/grs/Daemon.py
+++ b/grs/Daemon.py
@@ -9,6 +9,8 @@ import time
class Daemon:
""" doc here
more doc
+ Adopted from Sander Marechal's "A simple unix/linux daemon in Python"
+ See:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
"""
def __init__(self, pidfile, **kwargs):
@@ -41,7 +43,7 @@ class Daemon:
sys.stderr.write('fork #2 failed %s\n' % err)
sys.exit(1)
- # Close stdin, and redirect both stdout and stderr to
grs-daemon-<pid>.err
+ # Dup stdin to /dev/null, and stdout and stderr to grs-daemon-<pid>.err
si = open(os.devnull, 'r')
os.dup2(si.fileno(), sys.stdin.fileno())