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):
if self.pid == 0:
# Child
try:
os.execlp(command, command, *args)
sys.argv = [command] + args
execfile(command, {})
except (SystemExit, KeyboardInterrupt):
self._exit()
except:
print traceback.format_exc()
# If we reach this line, exec call failed (is it possible to reach
# it without going through above "except" branch ?).
print 'Error executing %r.' % (command + ' ' + ' '.join(args), )
# KeyboardInterrupt is not intercepted by test runner (it is still
# above us in the stack), and we do want to exit.
# To avoid polluting test foreground output with induced
# traceback, replace stdout & stderr.
sys.stdout = sys.stderr = open('/dev/null', 'w')
raise KeyboardInterrupt
self._exit()
def _exit(self):
# KeyboardInterrupt is not intercepted by test runner (it is still
# above us in the stack), and we do want to exit.
# 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):
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