From d2c4ee9e488f6c94865cc2f4c874d025bc2ae0d2 Mon Sep 17 00:00:00 2001 From: rsc Date: Mon, 24 Nov 2003 00:43:41 +0000 Subject: Tweaks to build properly on Linux. --- src/cmd/idiff.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/cmd/idiff.c') 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; } -- cgit v1.2.3