URI:
       topentemp.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       topentemp.c (255B)
       ---
            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 }