##// END OF EJS Templates
inotify: close most file descriptors when autostarting...
Brendan Cully -
r7451:fca99476 default
parent child Browse files
Show More
@@ -708,6 +708,26 b' class Master(object):'
708 708 timeobj.handle_timeout()
709 709
710 710 def start(ui, repo):
711 def closefds(ignore):
712 # (from python bug #1177468)
713 # close all inherited file descriptors
714 # Python 2.4.1 and later use /dev/urandom to seed the random module's RNG
715 # a file descriptor is kept internally as os._urandomfd (created on demand
716 # the first time os.urandom() is called), and should not be closed
717 try:
718 os.urandom(4)
719 urandom_fd = getattr(os, '_urandomfd', None)
720 except AttributeError:
721 urandom_fd = None
722 ignore.append(urandom_fd)
723 for fd in range(3, 256):
724 if fd in ignore:
725 continue
726 try:
727 os.close(fd)
728 except OSError:
729 pass
730
711 731 m = Master(ui, repo)
712 732 sys.stdout.flush()
713 733 sys.stderr.flush()
@@ -716,6 +736,7 b' def start(ui, repo):'
716 736 if pid:
717 737 return pid
718 738
739 closefds([m.server.fileno(), m.watcher.fileno()])
719 740 os.setsid()
720 741
721 742 fd = os.open('/dev/null', os.O_RDONLY)
General Comments 0
You need to be logged in to leave comments. Login now