| commit | a58a827f2ae0d989102dc4d8c113b9282ef177b3 | [log] [tgz] |
|---|---|---|
| author | Russ Cox <rsc@swtch.com> | Thu Jul 10 11:10:10 2008 -0400 |
| committer | Russ Cox <rsc@swtch.com> | Thu Jul 10 11:10:10 2008 -0400 |
| tree | ce7b160c3393224e05a2100615c9fe48d20d2e82 | |
| parent | c224dda84efaeb28ce66e59213f3cbfde06735ac [diff] [blame] |
lib9: add mode parameter to opentemp
diff --git a/src/lib9/opentemp.c b/src/lib9/opentemp.c index f90bf77..9d4e2d0 100644 --- a/src/lib9/opentemp.c +++ b/src/lib9/opentemp.c
@@ -2,14 +2,19 @@ #include <libc.h> int -opentemp(char *template) +opentemp(char *template, int mode) { - int fd; + int fd, fd1; fd = mkstemp(template); if(fd < 0) return -1; - remove(template); - return fd; + if((fd1 = open(template, mode)) < 0){ + remove(template); + close(fd); + return -1; + } + close(fd); + return fd1; }