[Top][All Lists]

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

Re: creat-safer vs. text mode platforms

From: Paul Eggert
Subject: Re: creat-safer vs. text mode platforms
Date: Wed, 15 Mar 2006 23:04:19 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Eric Blake <address@hidden> writes:

> Should we replace all uses of "creat (name, mode)" (such as in
> creat-safer.c) with "open (name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
> mode)", with O_BINARY properly defined to 0 on POSIX systems?

That might make sense for some instances of creat, but not the
instance in creat-safer.c.  POSIX says creat is equivalent to open
with O_WRONLY|O_CREAT|O_TRUNC, and my kneejerk reaction is that I'd
rather not second-guess this, even on Cygwin.

> Or should we just encourage GNU programs to use open instead of creat, so
> that they have explicit control over whether the O_BINARY flag is used,
> resulting in one less portability gotcha.

I would say that we should encourage the use of open over creat only
when it matters.  For tar, I guess it matters, since tar files are
inherently binary.  For other files it might not matter.

> Hmm, maybe something similar should be done for the recently removed
> asctime_r and ctime_r.

I suppose we could have a time-safer module, but is it really worth
the trouble?  Anybody who's likely to use it will already have swept
for ctime (which is by far the biggest problem), as well as for
asctime, ctime_r, and asctime_r.

reply via email to

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