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: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 2/4] Add cleanup function
Date: Fri, 13 Jan 2012 16:17:08 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

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?

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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