...
Code Block | ||
---|---|---|
| ||
char sfn[] = "temp-XXXXXX"; FILE *sfp; int fd = mkstemp(sfn); if (fd == -1) { /* Handle Error */ } /* * Unlink immediately to allowhide the name to be recycledfile name. * The race condition here is inconsequential if the file * is created with exclusive permissions (glibc >= 2.0.7) */ unlink(sfn); sfp = fdopen(fd, "w+"); if (sfp == NULL) { close(fd); /* Handle Error */ } /* use temporary file */ fclose(sfp); /* also closes fd */ |
...