Revision 638ac34b
b/lib/utils/process.py | ||
---|---|---|
251 | 251 |
# Open /dev/null (read-only, only for stdin) |
252 | 252 |
devnull_fd = os.open(os.devnull, os.O_RDONLY) |
253 | 253 |
|
254 |
output_close = True |
|
255 |
|
|
254 | 256 |
if output_fd is not None: |
255 |
pass
|
|
257 |
output_close = False
|
|
256 | 258 |
elif output_file is not None: |
257 | 259 |
# Open output file |
258 | 260 |
try: |
... | ... | |
268 | 270 |
os.dup2(output_fd, 1) |
269 | 271 |
os.dup2(output_fd, 2) |
270 | 272 |
|
273 |
if devnull_fd > 2: |
|
274 |
utils_wrapper.CloseFdNoError(devnull_fd) |
|
275 |
|
|
276 |
if output_close and output_fd > 2: |
|
277 |
utils_wrapper.CloseFdNoError(output_fd) |
|
278 |
|
|
271 | 279 |
|
272 | 280 |
def StartDaemon(cmd, env=None, cwd="/", output=None, output_fd=None, |
273 | 281 |
pidfile=None): |
Also available in: Unified diff