Mail Archives: djgpp-workers/1998/04/28/13:07:38
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 -