From ae4a4b903ee14dd5e8f5c8e106e3ed393b21c30d Mon Sep 17 00:00:00 2001 From: Rod A Santiago Date: Wed, 14 Sep 2016 17:13:46 -0700 Subject: [PATCH] Merged with new version from NRL --- daemon/core/session.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/daemon/core/session.py b/daemon/core/session.py index 070dc391..85fb49d3 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)) @@ -675,7 +684,6 @@ class Session(object): self.info("Checking for runtime with %d of %d session nodes" % \ (nc, session_node_count)) if nc < session_node_count: - self.info("do not have information on all nodes") return # do not have information on all nodes yet # information on all nodes has been received and they have been started # enter the runtime state @@ -684,7 +692,6 @@ class Session(object): state = coreapi.CORE_EVENT_RUNTIME_STATE self.evq.run() self.setstate(state, info=True, sendevent=True) - self.info("Entered runtime state") def datacollect(self): ''' Tear down a running session. Stop the event loop and any running @@ -759,7 +766,6 @@ class Session(object): | coreapi.CORE_API_LOC_FLAG, tlvdata) try: - #Use the handler's sendall (Is this ok with CoreDatagramRequestHandler??) handler.sendall(reply) except Exception, e: self.warn("sendall() for node: %d error: %s" % (nodenum, e))