Commit a8f53337 authored by Vincent Pelletier's avatar Vincent Pelletier

Exec scripts in the same (forked) interpreter.

Avoid switching to an unexpected interpreter after forking.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2230 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7755bc02
...@@ -82,18 +82,24 @@ class NEOProcess(object): ...@@ -82,18 +82,24 @@ class NEOProcess(object):
if self.pid == 0: if self.pid == 0:
# Child # Child
try: try:
os.execlp(command, command, *args) sys.argv = [command] + args
execfile(command, {})
except (SystemExit, KeyboardInterrupt):
self._exit()
except: except:
print traceback.format_exc() print traceback.format_exc()
# If we reach this line, exec call failed (is it possible to reach # If we reach this line, exec call failed (is it possible to reach
# it without going through above "except" branch ?). # it without going through above "except" branch ?).
print 'Error executing %r.' % (command + ' ' + ' '.join(args), ) print 'Error executing %r.' % (command + ' ' + ' '.join(args), )
# KeyboardInterrupt is not intercepted by test runner (it is still self._exit()
# above us in the stack), and we do want to exit.
# To avoid polluting test foreground output with induced def _exit(self):
# traceback, replace stdout & stderr. # KeyboardInterrupt is not intercepted by test runner (it is still
sys.stdout = sys.stderr = open('/dev/null', 'w') # above us in the stack), and we do want to exit.
raise KeyboardInterrupt # To avoid polluting test foreground output with induced
# traceback, replace stdout & stderr.
sys.stdout = sys.stderr = open('/dev/null', 'w')
raise KeyboardInterrupt
def kill(self, sig=signal.SIGTERM): def kill(self, sig=signal.SIGTERM):
if self.pid: if self.pid:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment