##// END OF EJS Templates
server: minor code cleanup...
Matt Harbison -
r37233:d2bd29df default
parent child Browse files
Show More
@@ -55,8 +55,8 b' def runservice(opts, parentfn=None, init'
55 55 fd = os.open(postexecargs['unlink'],
56 56 os.O_WRONLY | os.O_APPEND | os.O_BINARY)
57 57 try:
58 os.dup2(fd, 1)
59 os.dup2(fd, 2)
58 os.dup2(fd, procutil.stdout.fileno())
59 os.dup2(fd, procutil.stderr.fileno())
60 60 finally:
61 61 os.close(fd)
62 62
@@ -94,7 +94,7 b' def runservice(opts, parentfn=None, init'
94 94 # If the daemonized process managed to write out an error msg,
95 95 # report it.
96 96 if pycompat.iswindows and os.path.exists(lockpath):
97 with open(lockpath) as log:
97 with open(lockpath, 'rb') as log:
98 98 for line in log:
99 99 procutil.stderr.write(line)
100 100 raise error.Abort(_('child process failed to start'))
@@ -129,12 +129,14 b' def runservice(opts, parentfn=None, init'
129 129 if logfile:
130 130 logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND,
131 131 0o666)
132 os.dup2(nullfd, 0)
133 os.dup2(logfilefd, 1)
134 os.dup2(logfilefd, 2)
135 if nullfd not in (0, 1, 2):
132 os.dup2(nullfd, procutil.stdin.fileno())
133 os.dup2(logfilefd, procutil.stdout.fileno())
134 os.dup2(logfilefd, procutil.stderr.fileno())
135 stdio = (procutil.stdin.fileno(), procutil.stdout.fileno(),
136 procutil.stderr.fileno())
137 if nullfd not in stdio:
136 138 os.close(nullfd)
137 if logfile and logfilefd not in (0, 1, 2):
139 if logfile and logfilefd not in stdio:
138 140 os.close(logfilefd)
139 141
140 142 # Only unlink after redirecting stdout/stderr, so Windows doesn't
General Comments 0
You need to be logged in to leave comments. Login now