Subject: bug#15015: Fix some minor races in hosts lacking mkostemp

From: Paul Eggert <[email-masked]>
Date: Sat, 03 Aug 2013 14:26:20 -0700

On 08/03/2013 07:55 AM, Eli Zaretskii wrote:

> gettimeofday, open, and lstat are implemented by Emacs in w32.c.  At
> lest the last 2 are not equivalent to what gnulib uses.

The lack of equivalence shouldn't matter.  The lstat call
(though it is compiled) won't be used by Emacs's use of the
mkostemp module on Microsoft platforms, so it's OK.  
mkostemp always calls 'open' with O_CREAT | O_EXCL; in that
case sys_open is just a simple wrapper around _open, so that
should be OK too.  And gettimeofday, as you mentioned, isn't
a problem.

>> Presumably nt/configure.bat and makefile-w32.in could be updated
>> to compile the new files.  This sort of thing should be routine,
>> if that avenue is still supported.
>
> This "support" needs volunteers, which didn't yet show up.

If nobody's supporting it, then it's not really supported.
It's not a big deal -- if someone wants to start supporting
that build mechanism again, it'd be an easy-enough task.
In the meantime we needn't let a deprecated and
apparently-unsupported build mechanism get in the way of
fixing bugs in mainstream builds.

> We can always install the gnulib stuff for those other platforms

Yes, that's a given.  We need to do that, to fix the race
condition bugs in OS X, Solaris, etc.

> and work around it on Windows.

I'm trying to help save work in the Windows port, by having
Windows Emacs use Gnulib mkostemp (which will be in the
source code anyway) the same way it's being used on OS X etc.
If this approach is feasible, it should save us all some
work; if not, it should be easy for a Windows expert to work
around any problems in w32.c and/or msdos.c.