Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: reverted some of my changes to the CS

...

Code Block
bgColor#ccccff
char sfn[] = "/tmp/temp-XXXXXX";
FILE *sfp;
int fd = -1;

if (fd = mkstemp(sfn)) == -1) {
  /* Handle Error */
} else if (sfp = fdopen(fd, "w+")) == NULL) {
    unlink(sfn);
    close(fd);
  }
 else {
   /* Handle Error */
}
unlink(sfn); /* unlink immediately to allow name to be recycled*/
  /* use temporary file */
  fclose(sfp); /* also closes fd */
}

Wiki Markup
The Open Group Base Specification Issue 6 \[[Open Group 04|AA. C References#Open Group 04]\] does not specify the permissions the file is created with, so these are [implementation-defined|BB. Definitions#implementation-defined behavior]. However, Issue 7 (that is, POSIX.1-2008) specifies them as {{S_IRUSR\|S_IWUSR}} (0600).

...