Return to BSD News archive
Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!sdd.hp.com!cs.utexas.edu!sun-barr!ames!agate!usenet.ins.cwru.edu!gatech!rutgers!princeton!beam.Princeton.EDU!jsm From: jsm@beam.Princeton.EDU (John Scott McCauley Jr.) Newsgroups: comp.unix.bsd Subject: Re: mktemp - Bus Error. Message-ID: <1992Nov2.215333.1434@Princeton.EDU> Date: 2 Nov 92 21:53:33 GMT References: <6607@otc.otca.oz> <1992Nov2.210351.12723@ee.ryerson.ca> Sender: news@Princeton.EDU (USENET News System) Organization: Princeton University Lines: 38 Originator: news@nimaster Nntp-Posting-Host: beam.princeton.edu In article <1992Nov2.210351.12723@ee.ryerson.ca> elf@ee.ryerson.ca (luis fernandes) writes: >In article <6607@otc.otca.oz> alexk@otc.otca.oz.au (Alex Kowalenko) writes: >>I'm having problems with mktemp failing due to a Bus Error. Even a simple program like the >>following will fail: >> >>#include<stdio.h> >> >>main() >>{ >> printf("%s\n",mktemp("XXXX")); >>} >> >> >>Anyone else noticed this yet? Any fixes in mktemp? >> >According to the man: > > mktemp() creates a unique file name, typically in a tem- > porary filesystem, by replacing template with a unique file > name, and returns the address of template. The string in > template should contain a file name with six trailing Xs; > mktemp() replaces the Xs with a letter and the current pro- > cess ID. The letter will be chosen so that the resulting > name does not duplicate an existing file. > >Life goes on... > The above code, although incorrect, doesn't core dump under Sun-OS or Ultrix cc. You might need to specify '-fwritable-strings' if you are using GCC or try something like: char tempname[1024]; .... strcpy(tempname, "/tmp/foo.XXXXXX"); mktemp(tempname); Scott