[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/4] Add cleanup function
From: |
Ryan Harper |
Subject: |
Re: [Qemu-devel] [PATCH 2/4] Add cleanup function |
Date: |
Fri, 20 Jan 2012 09:33:02 -0600 |
User-agent: |
Mutt/1.5.6+20040907i |
* Eric Blake <address@hidden> [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 address@hidden +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
address@hidden
[Qemu-devel] [PATCH 4/4] Apply consistent indentation, Ryan Harper, 2012/01/13