From c612da3ea41b7dba630d748e2ff283037762cfcd Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 21 Feb 2007 13:45:48 +0000 Subject: [PATCH] new dump= override feature works --- virt-subproc/VirtSubproc.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/virt-subproc/VirtSubproc.py b/virt-subproc/VirtSubproc.py index 71b7725..9540197 100644 --- a/virt-subproc/VirtSubproc.py +++ b/virt-subproc/VirtSubproc.py @@ -56,7 +56,7 @@ def cmdnumargs(c, ce, nargs=0, noptargs=0): def cmd_capabilities(c, ce): cmdnumargs(c, ce) - return caller.hook_capabilities() + return caller.hook_capabilities() + ['execute-debug'] def cmd_quit(c, ce): cmdnumargs(c, ce) @@ -127,7 +127,7 @@ def down_python_script(gobody, functions=''): " if write: rw = os.O_WRONLY|os.O_CREAT\n" " else: rw = os.O_RDONLY\n" " nfd = os.open(fname, rw, mode)\n" - " os.dup2(nfd,fd)\n" + " if fd >= 0: os.dup2(nfd,fd)\n" + functions + "def go():\n" ) script += ( " os.environ['TMPDIR']= urllib.unquote('%s')\n" % @@ -161,12 +161,14 @@ def cmd_execute(c, ce): tfd = None if debug_g: (tfd,hfd) = m.groups() - gobody += " os.dup2(1,%d)\n" % int(tfd) + tfd = int(tfd) + gobody += " os.dup2(1,%d)\n" % tfd stdout = int(hfd) for ioe in range(3): - if ioe == tfd: continue + ioe_tfd = ioe + if ioe == tfd: ioe_tfd = -1 gobody += " setfd(%d,'%s',%d)\n" % ( - ioe, ce[ioe+2], ioe>0 ) + ioe_tfd, ce[ioe+2], ioe>0 ) gobody += " os.chdir(urllib.unquote('" + ce[5] +"'))\n" gobody += " cmd = '%s'\n" % ce[1] gobody += (" cmd = cmd.split(',')\n" -- 2.30.2