ref: bf322dfbf37c5b1ea392e6f36775a06cde96a942
parent: 370bfd26ce5ffd9a06a314a20d1691cc6b15b712
author: Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net>
date: Fri Dec 10 15:44:26 EST 2021
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.
--- 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 @@
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;