X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f Sender: rich AT phekda DOT freeserve DOT co DOT uk Message-ID: <3CAD9FB1.4DEC7F58@phekda.freeserve.co.uk> Date: Fri, 05 Apr 2002 13:59:29 +0100 From: Richard Dawe X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586) X-Accept-Language: de,fr MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: redirection problem with perl References: <3CAB1FDB DOT 68F9CF2F AT phekda DOT freeserve DOT co DOT uk> <7704-Fri05Apr2002112312+0300-eliz AT is DOT elta DOT co DOT il> <3CAD6FE7 DOT 1384C841 AT phekda DOT freeserve DOT co DOT uk> <8582-Fri05Apr2002142726+0300-eliz AT is DOT elta DOT co DOT il> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Hello. Eli Zaretskii wrote: [snip] > I guess that's because you can't create a file without asking to > write to it. That makes sense, but I have no idea if it's true. I'll write a test program later. > Should we reopen it with the correct open mode once it's created? mkstemp uses _creatnew. Making _creatnew reopen the file would introduce a race condition in mkstemp, because someone could sneak in between the close and reopen and perhaps open the file with exclusive access. This race condition defeats the point of having mkstemp in the first place. But mkstemp should return a file descriptor that can be used for reading and writing. So perhaps _creatnew should only close and reopen the file, when it needs to change mode to open the file after creating it? I.e.: O_WRONLY -> just open it O_RDONLY -> open it, close it, re-open it read-only O_RDWR -> just open it (Obviously this is based on needing to open for writing, to create the file.) Bye, Rich =] -- Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]