aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/idiff.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/idiff.c')
-rw-r--r--src/cmd/idiff.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/cmd/idiff.c b/src/cmd/idiff.c
index 47326782..c3f207fe 100644
--- a/src/cmd/idiff.c
+++ b/src/cmd/idiff.c
@@ -81,23 +81,12 @@ main(int argc, char **argv)
int
opentemp(char *template, int mode, long perm)
{
- int fd, i;
- char *p;
-
- p = strdup(template);
- if(p == nil)
- sysfatal("strdup out of memory");
- fd = -1;
- for(i=0; i<10; i++){
- mktemp(p);
- if(access(p, 0) < 0 && (fd=create(p, mode, perm)) >= 0)
- break;
- strcpy(p, template);
- }
+ int fd;
+
+ fd = mkstemp(template);
if(fd < 0)
sysfatal("could not create temporary file");
- strcpy(template, p);
- free(p);
+ fchmod(fd, perm);
return fd;
}