www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/04/09/04:05:09

From: mayoff AT dqd DOT com (Rob Mayoff)
Subject: bug in mkstemp
9 Apr 1998 04:05:09 -0700 :
Message-ID: <Pine.LNX.3.96.980408140347.10195D-100000.cygnus.gnu-win32@dqd.com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

In this program, the second call to mkstemp will fail:

#include <stdio.h>
#include <sys/param.h>

main()
{
  char path[MAXPATHLEN];
        int fd, rc;

        sprintf(path, "/tmp/test.XXXXXX");
        fd = mkstemp(path);
        if (fd < 0) { perror("mkstemp 1"); exit(1); }
        rc = unlink(path);
        if (rc < 0) { perror("unlink"); exit(1); }
        sprintf(path, "/tmp/test.XXXXXX");
        fd = mkstemp(path);
        if (fd < 0) { perror("mkstemp 2"); exit(1); }
        rc = unlink(path);
        if (rc < 0) { perror("unlink"); exit(1); }

        exit(0);
}

The fix should be simply to treat EACCES just like EEXIST in mkstemp.

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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