ref: 6d3daa4092f891a5e9a1762177f75c75a6d5adf9
parent: ef9b13875acedbb04515295f1e2782ebb517bc33
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;
--
⑨