chiark / gitweb /
virt-subproc: move making of temp directory into VirtSubproc (if method wants)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 25 Jul 2011 10:29:39 +0000 (11:29 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 25 Jul 2011 10:37:17 +0000 (11:37 +0100)
virt-subproc/VirtSubproc.py
virt-subproc/adt-virt-chroot

index 5cdf46eb2d293fb9af0506629ee59e6695e3e87e..8839fd0ac55d0b8ea487a3edf7568d67da67e48a 100644 (file)
@@ -128,6 +128,8 @@ def cmd_open(c, ce):
        cmdnumargs(c, ce)
        if downtmp: bomb("`open' when already open")
        downtmp = caller.hook_open()
+       if downtmp is None:
+               downtmp = execute('mktemp -t -d', downp=True, outp=True)
        debug("down = %s, downtmp = %s" % (string.join(down), downtmp))
        return [downtmp]
 
@@ -349,7 +351,10 @@ def cleanup():
        debug("cleanup...");
        sethandlers(signal.SIG_DFL)
        cleaning = True
-       if downtmp: caller.hook_cleanup()
+       if downtmp:
+               if not 'revert' in caller.hook_capabilities():
+                       execute('rm -rf --', [downtmp], downp=True)
+               caller.hook_cleanup()
        cleaning = False
        downtmp = False
 
index 9c96fbae181b273bb6e5f44c7619876fcb9a6d71..5d5f56f750bf4f86701ff3e970185a45f2a54e89 100755 (executable)
@@ -69,11 +69,10 @@ def parse_args():
 def hook_open():
        global downtmp
        vsp.execute('true', downp=True)
-       downtmp = vsp.execute('mktemp -t -d', downp=True, outp=True)
-       return downtmp
+       return None
 
 def hook_cleanup():
-       vsp.execute('rm -rf --', [downtmp], downp=True)
+       pass
 
 def hook_forked_inchild():
        pass