From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Fri, 28 Jan 2005 10:05:21 -0500 From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] mkstemp() In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: Topicbox-Message-UUID: 38304ae4-eace-11e9-9e20-41e7f4b1d025 Enjoy. int mkstemp(char *template) { char *s; int i, fd; s = strdup(template); if(s == nil) return -1; for(i=0; i<20; i++){ strcpy(s, template); mktemp(s); if((fd = create(s, ORDWR|OEXCL, 0666)) >= 0){ strcpy(template, s); free(s); return fd; } } free(s); return -1; } On Fri, 28 Jan 2005 14:39:41 +0100, cej@gli.cas.cz wrote: > need mkstemp() [BSD unistd.h] > any better idea than to copy the code from BSD | GNU ? > (I understand that returns a fd of a temp file) > > thanks, > ++pac. > >