SyntaxFix
Write A Post
Hire A Developer
Questions
You should use the python-daemon library, it takes care of everything.
From PyPI: Library to implement a well-behaved Unix daemon process.