From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:40499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoGXB-0001pq-6z for qemu-devel@nongnu.org; Fri, 20 Jan 2012 10:37:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RoGX5-0002qV-9Y for qemu-devel@nongnu.org; Fri, 20 Jan 2012 10:37:45 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:46631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RoGX4-0002oq-BS for qemu-devel@nongnu.org; Fri, 20 Jan 2012 10:37:38 -0500 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 20 Jan 2012 08:37:29 -0700 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id 49A573E40171 for ; Fri, 20 Jan 2012 08:33:44 -0700 (MST) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q0KFXDsG099380 for ; Fri, 20 Jan 2012 08:33:17 -0700 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q0KFX65I022946 for ; Fri, 20 Jan 2012 10:33:06 -0500 Date: Fri, 20 Jan 2012 09:33:02 -0600 From: Ryan Harper Message-ID: <20120120153302.GD18501@us.ibm.com> References: <1326492321-13540-1-git-send-email-ryanh@us.ibm.com> <1326492321-13540-3-git-send-email-ryanh@us.ibm.com> <4F10BB74.4050308@redhat.com> <20120116171640.GB25198@us.ibm.com> <4F15F028.3050302@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F15F028.3050302@redhat.com> Subject: Re: [Qemu-devel] [PATCH 2/4] Add cleanup function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Ryan Harper , qemu-devel@nongnu.org * Eric Blake [2012-01-17 16:03]: > On 01/16/2012 10:16 AM, Ryan Harper wrote: > >>> if test -z "$1" -o -z "$2"; then > >>> echo "Usage: $0 QEMU TEST1 [TEST2 ...]" > >>> + cleanup > >>> exit 1 > >> > >> Is it worth using 'trap cleanup 0' to install the cleanup handler up > >> front, instead of modifying all exit call sites? > > > > I thought about that, but it seemed to require switching to /bin/bash > > Not really. > > > > > and I know Anthony had written the scripts carefully to be /bin/sh. > > POSIX requires /bin/sh to support 'trap cleanup 0', and I don't know of I was using trap cleanup SIGINT; which /bin/sh didn't like: (finalgravity) qemu-test % ./qemu-test ~/work/git/qemu/x86_64-softmmu/qemu-system-x86_64 tests/virtio-serial.sh trap: SIGINT: bad trap but with 0 instead, that seems to work. > any counter-example shells that fail to do this. There are non-POSIX > shells where installing a trap 0 handler from inside a function body > invokes the handler upon exiting the function, instead of exiting the > overall script, but even Solaris /bin/sh knows how to correctly handle a > trap 0 handler installed outside of any function calls. > > https://www.gnu.org/software/autoconf/manual/autoconf.html#trap > > -- > Eric Blake eblake@redhat.com +1-919-301-3266 > Libvirt virtualization library http://libvirt.org > -- Ryan Harper Software Engineer; Linux Technology Center IBM Corp., Austin, Tx ryanh@us.ibm.com