Merge "Use built-in subprocess.DEVNULL"

This commit is contained in:
Zuul 2024-02-10 15:24:46 +00:00 committed by Gerrit Code Review
commit 50c6680a55
1 changed files with 3 additions and 5 deletions

View File

@ -130,15 +130,13 @@ class StorletDaemonFactory(SBusServer):
self.logger.debug('Starting subprocess: pargs:{0} env:{1}'
.format(str_pargs, env))
# TODO(takashi): We had better use contextmanager
# TODO(takashi): Where is this closed?
try:
dn = open(os.devnull, 'wb')
daemon_p = subprocess.Popen(
pargs, stdout=dn, stderr=subprocess.PIPE,
pargs, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,
close_fds=True, shell=False, env=env)
logger_p = subprocess.Popen(
'logger', stdin=daemon_p.stderr, stdout=dn, stderr=dn,
'logger', stdin=daemon_p.stderr,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
close_fds=True, shell=False)
except OSError:
self.logger.exception('Unable to start subprocess')