diff options
author | Russ Cox <rsc@swtch.com> | 2008-07-10 11:10:10 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2008-07-10 11:10:10 -0400 |
commit | a58a827f2ae0d989102dc4d8c113b9282ef177b3 (patch) | |
tree | ce7b160c3393224e05a2100615c9fe48d20d2e82 /src/lib9 | |
parent | c224dda84efaeb28ce66e59213f3cbfde06735ac (diff) | |
download | plan9port-a58a827f2ae0d989102dc4d8c113b9282ef177b3.tar.gz plan9port-a58a827f2ae0d989102dc4d8c113b9282ef177b3.tar.bz2 plan9port-a58a827f2ae0d989102dc4d8c113b9282ef177b3.zip |
lib9: add mode parameter to opentemp
Diffstat (limited to 'src/lib9')
-rw-r--r-- | src/lib9/opentemp.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/lib9/opentemp.c b/src/lib9/opentemp.c index f90bf771..9d4e2d07 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; } |