summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Duraffourg <>2014-06-26 17:45:05 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-06-26 17:45:05 +0200
commit6698ed806e820ab438e4cf6e53a6e99924b819f0 (patch)
tree73678fb5b45d93ab811b929b1a4814fd2ed3deeb
parentc1803944bae4fe799a49013ffd4bf623363a5c6b (diff)
downloadpoezio-6698ed806e820ab438e4cf6e53a6e99924b819f0.tar.gz
poezio-6698ed806e820ab438e4cf6e53a6e99924b819f0.tar.bz2
poezio-6698ed806e820ab438e4cf6e53a6e99924b819f0.tar.xz
poezio-6698ed806e820ab438e4cf6e53a6e99924b819f0.zip
Redirect stderr to /dev/null when executing a command
fix #2545
-rwxr-xr-xsrc/daemon.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/daemon.py b/src/daemon.py
index 1b976282..395054a7 100755
--- a/src/daemon.py
+++ b/src/daemon.py
@@ -25,6 +25,12 @@ import subprocess
import shlex
import logging
+try:
+ from subprocess import DEVNULL # Only in python >= 3.3
+except ImportError:
+ import os
+ DEVNULL = open(os.devnull, 'wb')
+
log = logging.getLogger(__name__)
class Executor(threading.Thread):
@@ -51,7 +57,7 @@ class Executor(threading.Thread):
def run(self):
log.debug('executing %s', self.command)
- stdout = None
+ stdout = DEVNULL
if self.filename:
try:
stdout = open(self.filename, self.redirection_mode)
@@ -59,7 +65,7 @@ class Executor(threading.Thread):
log.error('Could not open redirection file: %s', self.filename, exc_info=True)
return
try:
- subprocess.call(self.command, stdout=stdout)
+ subprocess.call(self.command, stdout=stdout, stderr=DEVNULL)
except:
if self.remote:
import traceback