diff --git a/lib/utils.py b/lib/utils.py
index 509f8be77265a8faed5f9939ac547784383f2b93..a1f15d50bd1dcf829e07bd1abfd1ec36c142fbd5 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -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:
+      continue
     try:
       os.close(fd)
     except OSError: # ERROR, fd wasn't open to begin with (ignored)