Mail Archives: djgpp-workers/1998/04/28/12:05:56
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.)
> Note: I didn't find _createnew in djlsr202 and also in djgpp-workers mailing list
> so I used
> open ( name , O_RDWR+O_EXCL+O_CREAT , S_IWUSR+S_IPUSR )
> that should be equivalent to _createnewl
No, _creatnew is different. I send you in a separate message a patch
which will create it.
*** src/libc/compat/stdio/mkstemp.c~1 Thu Apr 23 15:24:46 1998
--- src/libc/compat/stdio/mkstemp.c Tue Apr 28 18:50:18 1998
*************** mkstemp (char *_template)
*** 13,22 ****
/* Make sure we create a non-exisiting file, even
if race conditions exist with other processes. */
! do
strcpy(tmp_name, _template);
! while (mktemp (tmp_name) != NULL
! && (fd = _creatnew(tmp_name, 0, SH_DENYRW)) == -1);
if (fd == -1)
errno = ENOENT;
--- 13,24 ----
/* Make sure we create a non-exisiting file, even
if race conditions exist with other processes. */
! do {
strcpy(tmp_name, _template);
! errno = 0;
! } while (mktemp (tmp_name) != NULL
! && (fd = _creatnew(tmp_name, 0, SH_DENYRW)) == -1
! && errno != ENOENT);
if (fd == -1)
errno = ENOENT;
*** src/libc/ansi/stdio/tmpfile.c~1 Thu Apr 23 15:21:40 1998
--- src/libc/ansi/stdio/tmpfile.c Tue Apr 28 18:53:00 1998
***************
*** 4,9 ****
--- 4,10 ----
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+ #include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <io.h>
*************** tmpfile(void)
*** 28,36 ****
moment when we actually open the file below. This loop
retries the call to `tmpnam' until we actually succeed
to create the file which didn't exist before. */
! do
temp_fd = _creatnew(temp_name, 0, SH_DENYRW);
! while (temp_fd == -1 && (temp_name = tmpnam(0)) != 0);
if (temp_name == 0)
return 0;
--- 29,38 ----
moment when we actually open the file below. This loop
retries the call to `tmpnam' until we actually succeed
to create the file which didn't exist before. */
! do {
! errno = 0;
temp_fd = _creatnew(temp_name, 0, SH_DENYRW);
! } while (temp_fd == -1 && errno != ENOENT && (temp_name = tmpnam(0)) != 0);
if (temp_name == 0)
return 0;
- Raw text -