nmh-workers
[Top][All Lists]
Advanced

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

Re: [Nmh-workers] tempfile creation


From: Josh Bressers
Subject: Re: [Nmh-workers] tempfile creation
Date: Wed, 27 Apr 2005 14:52:37 -0500
User-agent: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324)

Chad Walstrom wrote:
> On Wed, Apr 27, 2005 at 11:01:45AM -0400, Mike O'Dell wrote:
> 
>>if i were to hazzard a guess, the reason the code doesn't use
>>mkstemp() is that [1] the code cited is likely well more than twice
>>age of mkstemp() [2]and nobody has gone looking for things to fix
>>that were still (apparently) working. (big grin)
> 
> 
> In sbr/m_scratch.c, it looks like there's a comment made by "Doug"
> with respect to postponing the mkstemp(3) work until "later".
> Additionally, looking at the manpage for mkstemp(3) on a GNU/Linux
> system reports this note::
> 
>    "Don't  use  this  function, use tmpfile(3) instead.  It is better
>    defined and more portable."
> 
> Neither tmpfile(3) nor mkstemp(3) give a file name as a return value,
> rather a file stream or file descriptor, respectively.  This breaks
> the use of a temp file as a staging area for a potentially permanent
> file (ala rename(2) or link(2)) and would require a more extensive
> rewrite of the nmh utilities.

mkstemp is more like the usage of mktemp, and is portable.  mkstemp has
been a part of POSIX since 2001.  It's already used in various places in
the nmh source (search for it).  The tmpfile specification doesn't
guarantee that the file will be unique, but on most non ancient libc's,
it should be.

The biggest advantage of mkstemp is that it gives you back the name of
the temp file it just created, tempfile doesn't.

-- 
    JB




reply via email to

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