Commit 8ff612c2 authored by Iustin Pop's avatar Iustin Pop
Browse files

Allow utils.Daemonize() to not close some fds

This patch implements an optional parameter to utils.Daemonize() which
allows that function to not close some file descriptors.

This will allow the master daemon to open the listening socket before
fork - in order to be able to notify errors and return a meaningful exit
code, and then when we fork we don't close that fd.

Reviewed-by: imsnah
parent 7a1ecaed
......@@ -1083,7 +1083,7 @@ def TestDelay(duration):
return True
def Daemonize(logfile):
def Daemonize(logfile, noclose_fds=None):
"""Daemonize the current process.
This detaches the current process from the controlling terminal and
......@@ -1123,6 +1123,8 @@ def Daemonize(logfile):
# Iterate through and close all file descriptors.
for fd in range(0, maxfd):
if noclose_fds and fd in noclose_fds:
except OSError: # ERROR, fd wasn't open to begin with (ignored)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment