diff options
author | Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net> | 2021-12-10 20:44:26 +0000 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2021-12-10 20:44:26 +0000 |
commit | bf322dfbf37c5b1ea392e6f36775a06cde96a942 (patch) | |
tree | cbff0c8e46e305cf33f7ec4af7a2379f34965c22 /sys/src/ape | |
parent | 370bfd26ce5ffd9a06a314a20d1691cc6b15b712 (diff) |
ape/mkstemp: better options
Use O_EXCL and make the file descriptor writeable. This is more
usefull and it conforms to Single Unix and other specs.
Diffstat (limited to 'sys/src/ape')
-rw-r--r-- | sys/src/ape/lib/ap/gen/mkstemp.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/src/ape/lib/ap/gen/mkstemp.c b/sys/src/ape/lib/ap/gen/mkstemp.c index ef2169b59..7dd6e2dde 100644 --- a/sys/src/ape/lib/ap/gen/mkstemp.c +++ b/sys/src/ape/lib/ap/gen/mkstemp.c @@ -1,6 +1,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <fcntl.h> int mkstemp(char *template) @@ -14,7 +15,7 @@ mkstemp(char *template) for(i=0; i<20; i++){ strcpy(s, template); mktemp(s); - if((fd = creat(s, 0666)) >= 0){ + if((fd = open(s, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0){ strcpy(template, s); free(s); return fd; |