mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 05:33:37 +00:00
Testing fix for freenas
This commit is contained in:
parent
0ae8b5429b
commit
da826d24d4
1 changed files with 17 additions and 34 deletions
45
SickBeard.py
45
SickBeard.py
|
@ -97,35 +97,27 @@ def loadShowsFromDB():
|
|||
|
||||
# TODO: update the existing shows if the showlist has something in it
|
||||
|
||||
|
||||
def daemonize():
|
||||
"""
|
||||
Fork off as a daemon
|
||||
"""
|
||||
|
||||
# pylint: disable=E1101
|
||||
# Make a non-session-leader child process
|
||||
try:
|
||||
pid = os.fork() # @UndefinedVariable - only available in UNIX
|
||||
if pid != 0:
|
||||
os._exit(0)
|
||||
except OSError, e:
|
||||
sys.stderr.write("fork #1 failed: %d (%s)\n" % (e.errno, e.strerror))
|
||||
pid = os.fork()
|
||||
if pid > 0:
|
||||
sys.exit(0)
|
||||
except OSError:
|
||||
print "fork() failed"
|
||||
sys.exit(1)
|
||||
|
||||
os.setsid() # unix
|
||||
|
||||
os.chdir(sickbeard.PROG_DIR)
|
||||
os.setsid()
|
||||
# Make sure I can read my own files and shut out others
|
||||
prev= os.umask(0)
|
||||
os.umask(prev and int('077',8))
|
||||
|
||||
# Make the child a session-leader by detaching from the terminal
|
||||
try:
|
||||
pid = os.fork() # @UndefinedVariable - only available in UNIX
|
||||
if pid != 0:
|
||||
os._exit(0)
|
||||
except OSError, e:
|
||||
sys.stderr.write("fork #2 failed: %d (%s)\n" % (e.errno, e.strerror))
|
||||
pid = os.fork()
|
||||
if pid > 0:
|
||||
sys.exit(0)
|
||||
except OSError:
|
||||
print "fork() failed"
|
||||
sys.exit(1)
|
||||
|
||||
# Write pid
|
||||
|
@ -139,17 +131,8 @@ def daemonize():
|
|||
u"Unable to write PID file: " + sickbeard.PIDFILE + " Error: " + str(e.strerror) + " [" + str(
|
||||
e.errno) + "]")
|
||||
|
||||
# Redirect all output
|
||||
sys.stdout.flush()
|
||||
sys.stderr.flush()
|
||||
|
||||
devnull = getattr(os, 'devnull', '/dev/null')
|
||||
stdin = file(devnull, 'r')
|
||||
stdout = file(devnull, 'a+')
|
||||
stderr = file(devnull, 'a+')
|
||||
os.dup2(stdin.fileno(), sys.stdin.fileno())
|
||||
os.dup2(stdout.fileno(), sys.stdout.fileno())
|
||||
os.dup2(stderr.fileno(), sys.stderr.fileno())
|
||||
dev_null = file('/dev/null', 'r')
|
||||
os.dup2(dev_null.fileno(), sys.stdin.fileno())
|
||||
|
||||
def main():
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue