Show More
@@ -55,8 +55,8 b' def runservice(opts, parentfn=None, init' | |||||
55 | fd = os.open(postexecargs['unlink'], |
|
55 | fd = os.open(postexecargs['unlink'], | |
56 | os.O_WRONLY | os.O_APPEND | os.O_BINARY) |
|
56 | os.O_WRONLY | os.O_APPEND | os.O_BINARY) | |
57 | try: |
|
57 | try: | |
58 |
os.dup2(fd, |
|
58 | os.dup2(fd, procutil.stdout.fileno()) | |
59 |
os.dup2(fd, |
|
59 | os.dup2(fd, procutil.stderr.fileno()) | |
60 | finally: |
|
60 | finally: | |
61 | os.close(fd) |
|
61 | os.close(fd) | |
62 |
|
62 | |||
@@ -94,7 +94,7 b' def runservice(opts, parentfn=None, init' | |||||
94 | # If the daemonized process managed to write out an error msg, |
|
94 | # If the daemonized process managed to write out an error msg, | |
95 | # report it. |
|
95 | # report it. | |
96 | if pycompat.iswindows and os.path.exists(lockpath): |
|
96 | if pycompat.iswindows and os.path.exists(lockpath): | |
97 | with open(lockpath) as log: |
|
97 | with open(lockpath, 'rb') as log: | |
98 | for line in log: |
|
98 | for line in log: | |
99 | procutil.stderr.write(line) |
|
99 | procutil.stderr.write(line) | |
100 | raise error.Abort(_('child process failed to start')) |
|
100 | raise error.Abort(_('child process failed to start')) | |
@@ -129,12 +129,14 b' def runservice(opts, parentfn=None, init' | |||||
129 | if logfile: |
|
129 | if logfile: | |
130 | logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND, |
|
130 | logfilefd = os.open(logfile, os.O_RDWR | os.O_CREAT | os.O_APPEND, | |
131 | 0o666) |
|
131 | 0o666) | |
132 |
os.dup2(nullfd, |
|
132 | os.dup2(nullfd, procutil.stdin.fileno()) | |
133 |
os.dup2(logfilefd, |
|
133 | os.dup2(logfilefd, procutil.stdout.fileno()) | |
134 |
os.dup2(logfilefd, |
|
134 | os.dup2(logfilefd, procutil.stderr.fileno()) | |
135 | if nullfd not in (0, 1, 2): |
|
135 | stdio = (procutil.stdin.fileno(), procutil.stdout.fileno(), | |
|
136 | procutil.stderr.fileno()) | |||
|
137 | if nullfd not in stdio: | |||
136 | os.close(nullfd) |
|
138 | os.close(nullfd) | |
137 |
if logfile and logfilefd not in |
|
139 | if logfile and logfilefd not in stdio: | |
138 | os.close(logfilefd) |
|
140 | os.close(logfilefd) | |
139 |
|
141 | |||
140 | # Only unlink after redirecting stdout/stderr, so Windows doesn't |
|
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