From b28b4fcd6e9d954643239deed9804db30dd2ef31 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 1 Jan 2011 16:25:08 +0100 Subject: fixed daemon mode --- pyLoadCore.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'pyLoadCore.py') diff --git a/pyLoadCore.py b/pyLoadCore.py index eb990bab7..f3c9bef6c 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -889,13 +889,8 @@ def deamon(): print >>sys.stderr, "fork #2 failed: %d (%s)" % (e.errno, e.strerror) sys.exit(1) - from resource import getrlimit, RLIMIT_NOFILE, RLIM_INFINITY # Resource usage information. - maxfd = getrlimit(RLIMIT_NOFILE)[1] - if maxfd == RLIM_INFINITY: - maxfd = 1024 - - # Iterate through and close all file descriptors. - for fd in range(0, maxfd): + # Iterate through and close some file descriptors. + for fd in range(0, 3): try: os.close(fd) except OSError: # ERROR, fd wasn't open to begin with (ignored) @@ -914,12 +909,12 @@ if __name__ == "__main__": if "--daemon" in sys.argv: deamon() - - pyload_core = Core() - try: - pyload_core.start() - except KeyboardInterrupt: - pyload_core.shutdown() - pyload_core.log.info(_("killed pyLoad from Terminal")) - pyload_core.removeLogger() - _exit(1) + else: + pyload_core = Core() + try: + pyload_core.start() + except KeyboardInterrupt: + pyload_core.shutdown() + pyload_core.log.info(_("killed pyLoad from Terminal")) + pyload_core.removeLogger() + _exit(1) -- cgit v1.2.3