delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/04/28/13:07:38

Message-ID: <B0000028861@stargate.astr.lu.lv>
From: "Andris Pavenis" <pavenis AT lanet DOT lv>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Date: Tue, 28 Apr 1998 20:03:19 +0300
MIME-Version: 1.0
Subject: Re: mkstemp.c
CC: djgpp-workers AT delorie DOT com, DJ Delorie <dj AT delorie DOT com>
References: <B0000028850 AT stargate DOT astr DOT lu DOT lv>
In-reply-to: <Pine.SUN.3.91.980428190139.28333A-100000@is>

Date sent:      	Tue, 28 Apr 1998 19:04:46 +0300 (IDT)
From:           	Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Subject:        	Re: mkstemp.c

> 
> On Tue, 28 Apr 1998, Andris Pavenis wrote:
> 
> > When I'm calling 
> >    mkstemp ("C:/aaaa/aaXXXXXX")    
> > 
> > and directory C:/aaaa does not exist then mkstemp will go into almost 
> > infinite for normal user loop (2^30 loops) because mktemp() return not NULL and 
> > _createnew returns -1 (error) but we are not looking for error code of _createnew.
> 
> Does the patch below solves this?  (I also send a similar patch for 
> tmpfile, in case you need it.)
>

I think following is more safe. I think we should exclude other error codes
except EEXIST ( I tested that I'm getting this code even if there is directory
or R/O file with conflicting name, so all worked Ok). I'm didn't make patch
for tempnam() as I don't need it currently. 

Looks that these procedures are working correctly together with others
from djdev201 so I'm not going now to change to djdev202 fully. Perhaps
I'll combine necessary procedures from 202 in one file (together with some
modifications especially for gcc) and use it as additional module for building
gcc (no more such ugly hacks as I talked before)

Andris

*** mkstemp.c~	Tue Apr 28 19:33:16 1998
--- mkstemp.c	Tue Apr 28 19:44:06 1998
***************
*** 18,24 ****
      errno = 0;
    } while (mktemp (tmp_name) != NULL
  	   && (fd = _creatnew(tmp_name, 0, SH_DENYRW)) == -1
! 	   && errno != ENOENT);
  
    if (fd == -1)
      errno = ENOENT;
--- 18,24 ----
      errno = 0;
    } while (mktemp (tmp_name) != NULL
  	   && (fd = _creatnew(tmp_name, 0, SH_DENYRW)) == -1
! 	   && errno == EEXIST);
  
    if (fd == -1)
      errno = ENOENT;
 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019