[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH] configure: Put tempfiles in subd

From: Eric Blake
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] configure: Put tempfiles in subdir so we can clean up libtool files
Date: Tue, 06 May 2014 08:36:27 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

On 05/06/2014 07:17 AM, Peter Maydell wrote:
> When libtool support was added to configure, the new temporary files
> were left out of the list of files cleaned up on exit; this results
> in a lot of stale .lo files being left around in /tmp. Worse, libtool
> creates a /tmp/.libs directory which we can't easily clean up.
> Put all our temporary files in a single temporary directory created
> via mktemp -d, so we can easily clean it up. This has the bonus
> result that we no longer use $RANDOM (which silently expands to the
> empty string if your shell is not bash, and so is pretty useless).
> Note that because we now use mktemp's tempdir-finding logic rather
> than handrolling it, we no longer honour TEMPDIR (only TMPDIR).
> Signed-off-by: Peter Maydell <address@hidden>
> ---
> I don't know why we were looking at TEMPDIR; that code was
> in there from the initial commit by Fabrice back in 2003...

> +
> +TMPDIR1=$(mktemp -t -d)

mktemp is not POSIX.  BSD mktemp lacks -t:


and there are probably systems that lack mktemp(1) altogether.  You'll
need to come up with a more portable alternative.

Here's what autoconf recommends (modify to fit...):

# Create a (secure) tmp directory for tmp files.

  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
  test -d "$tmp"
}  ||
  (umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5

The use of $$ and $RANDOM is safe (even on shells that lack $RANDOM)
because of the fact that mkdir is atomic and the umask is correctly set
prior to the mkdir.

Eric Blake   eblake redhat com    +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]