[Top][All Lists]

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

Re: mkstemps

From: Eric Blake
Subject: Re: mkstemps
Date: Mon, 29 Jun 2009 16:20:46 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Bruno Haible <bruno <at> clisp.org> writes:

> > git recently started using mkstemps on systems that provide it (new enough
> > Solaris has it in <stdlib.h>, some BSD have it in <unistd.h> even though
> > it is not standardized,
> Indeed, the platforms that have it are: OpenBSD >= 2.4, FreeBSD >= 2.4,
> MacOS X [1], OpenSolaris [2].

And in inconsistent locations (some in <unistd.h>, even though it is not 
standardized; others in <stdlib.h> alongside the other mk*temp* functions).

> It can also be done by using mkdtemp and then creating a file with arbitrary
> name in the temporary directory. That approach is also more extensible: It
> allows not only the suffix, but the entire file name to be a given one. It
> keeps several temporary files from a single process together. It reduces the
> amount of directory entries in /tmp.

But it has the following drawback that the git developers wanted to avoid - 
there are some non-standard filesystems where rename() fails on cross-directory 
moves, but works when source and target live in the same directory.  While I 
agree that mkdtemp is the better approach for standards compliance, it loses 
flexibility by creating cross-directory situations not present with mkstemps.

> > Should we modify tempname.c's gen_tempname to also provide the 
> > ability to implement mkstemps?
> If you find this function worth using, no objection.

I personally don't have a use for it (yet).  I guess at this point I'll just 
wait and see if glibc adds it before worrying about it in gnulib.

Eric Blake

reply via email to

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