From 9a7b20515d8bae5762d26ef3889def8bbd47efd6 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 17 May 2007 14:33:39 +0100 Subject: [PATCH] Truncate files when writing them (!); fix message not to have spurious \; reset signal handlers in cleanup --- runner/adt-run | 5 +++-- virt-subproc/VirtSubproc.py | 14 ++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/runner/adt-run b/runner/adt-run index 9a4c686..2552988 100755 --- a/runner/adt-run +++ b/runner/adt-run @@ -613,8 +613,9 @@ def parse_args(): elif kindpath.endswith('/'): kind = 'tree' constructor = InputDir - else: parser.error("do not know how to handle filename \`%s';" - " specify --source --binary or --build-tree") + else: parser.error("do not know how to handle filename `%s';" + " specify --source --binary or --build-tree" % + kindpath) what = '%s%s' % (kind,ix); ix += 1 diff --git a/virt-subproc/VirtSubproc.py b/virt-subproc/VirtSubproc.py index 6c17f52..9f16c4b 100644 --- a/virt-subproc/VirtSubproc.py +++ b/virt-subproc/VirtSubproc.py @@ -136,7 +136,7 @@ def down_python_script(gobody, functions=''): "import os\n" "def setfd(fd,fnamee,write,mode=0666):\n" " fname = urllib.unquote(fnamee)\n" - " if write: rw = os.O_WRONLY|os.O_CREAT\n" + " if write: rw = os.O_WRONLY|os.O_CREAT|os.O_TRUNC\n" " else: rw = os.O_RDONLY\n" " nfd = os.open(fname, rw, mode)\n" " if fd >= 0: os.dup2(nfd,fd)\n" @@ -325,9 +325,16 @@ def command(): r = fc.e print string.join(r) +signal_list = [ signal.SIGHUP, signal.SIGTERM, + signal.SIGINT, signal.SIGPIPE ] + +def sethandlers(f): + for signum in signal_list: signal.signal(signum, f) + def cleanup(): global downtmp, cleaning debug("cleanup..."); + sethandlers(signal.SIG_DFL) cleaning = True if downtmp: caller.hook_cleanup() cleaning = False @@ -354,12 +361,7 @@ def error_cleanup(): def prepare(): global downtmp, cleaning downtmp = None - signal_list = [ signal.SIGHUP, signal.SIGTERM, - signal.SIGINT, signal.SIGPIPE ] - def sethandlers(f): - for signum in signal_list: signal.signal(signum, f) def handler(sig, *any): - sethandlers(signal.SIG_DFL) cleanup() os.kill(os.getpid(), sig) sethandlers(handler) -- 2.30.2