From e5e75756eac94bb3a66609b4f82fa35cea7a58f5 Mon Sep 17 00:00:00 2001 From: Tom Goff Date: Mon, 5 Sep 2016 17:11:10 -0400 Subject: [PATCH] daemon: Remove session-related changes introduced by 68532cb. --- daemon/core/session.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/daemon/core/session.py b/daemon/core/session.py index 9e226f53..223bd9e9 100644 --- a/daemon/core/session.py +++ b/daemon/core/session.py @@ -14,6 +14,7 @@ that manages a CORE session. import os, sys, tempfile, shutil, shlex, atexit, gc, pwd import threading, time, random import traceback +import subprocess from core.api import coreapi if os.uname()[0] == "Linux": @@ -289,8 +290,16 @@ class Session(object): self.warn("Error writing hook '%s': %s" % (filename, e)) self.info("Running hook %s for state %s" % (filename, state)) try: - check_call(["/bin/sh", filename], cwd=self.sessiondir, - env=self.getenviron()) + stdout = open(os.path.join(self.sessiondir, + filename + '.log'), 'w') + stderr = subprocess.STDOUT + except: + stdout = None + stderr = None + try: + check_call(["/bin/sh", filename], stdin=open(os.devnull, 'r'), + stdout=stdout, stderr=stderr, close_fds=True, + cwd=self.sessiondir, env=self.getenviron()) except Exception, e: self.warn("Error running hook '%s' for state %s: %s" % (filename, state, e))