| opentemp.c - 9base - revived minimalist port of Plan 9 userland to Unix | |
| git clone git://git.suckless.org/9base | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| opentemp.c (256B) | |
| --- | |
| 1 #include <u.h> | |
| 2 #include <libc.h> | |
| 3 | |
| 4 int | |
| 5 opentemp(char *template, int mode) | |
| 6 { | |
| 7 int fd, fd1; | |
| 8 | |
| 9 fd = mkstemp(template); | |
| 10 if(fd < 0) | |
| 11 return -1; | |
| 12 if((fd1 = open(template, mode)) < 0){ | |
| 13 remove(template); | |
| 14 close(fd); | |
| 15 return -1; | |
| 16 } | |
| 17 close(fd); | |
| 18 return fd1; | |
| 19 } | |
| 20 |