qemu-devel
[Top][All Lists]
Advanced

[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: Mon, 16 Jan 2012 11:16:40 -0600
User-agent: Mutt/1.5.6+20040907i

* Eric Blake <address@hidden> [2012-01-13 17:18]:
> On 01/13/2012 03:05 PM, Ryan Harper wrote:
> > Create a cleanup function and call it from all exits so we don't leave
> > temp files and directories around since we change the name on each 
> > invocation.
> > 
> > Also,  no need to delete the files in the tmpdir, so just remove the tmpdir
> > if it exists.
> > 
> > Signed-off-by: Ryan Harper <address@hidden>
> > ---
> >  qemu-test |   11 +++++++++--
> >  1 files changed, 9 insertions(+), 2 deletions(-)
> > 
> > diff --git a/qemu-test b/qemu-test
> > index cd102a7..71c1ba1 100755
> > --- a/qemu-test
> > +++ b/qemu-test
> > @@ -1,7 +1,14 @@
> >  #!/bin/sh
> >  
> > +cleanup() {
> > +    if test -n "$tmpdir"; then
> > +    rm -rf $tmpdir;
> > +    fi
> > +}
> > +
> >  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

and I know Anthony had written the scripts carefully to be /bin/sh.

> 
> -- 
> 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]