diff --git a/src/daemon.py b/src/daemon.py index 1b97628..75533bc 100755 --- a/src/daemon.py +++ b/src/daemon.py @@ -24,6 +24,7 @@ import threading import subprocess import shlex import logging +import os log = logging.getLogger(__name__) @@ -40,7 +41,7 @@ class Executor(threading.Thread): self.command = command self.remote = remote # check for > or >> special case - self.filename = None + self.filename = os.devnull self.redirection_mode = 'w' if len(command) >= 3: if command[-2] in ('>', '>>'): @@ -58,8 +59,13 @@ class Executor(threading.Thread): except (OSError, IOError): log.error('Could not open redirection file: %s', self.filename, exc_info=True) return + stderr = None try: - subprocess.call(self.command, stdout=stdout) + stderr = open(os.devnull, 'w') + except (OSError, IOError): + log.error('Could not open stderr file: %s', os.devnull, exc_info=True) + try: + subprocess.call(self.command, stdout=stdout, stderr=stderr) except: if self.remote: import traceback