*BSD News Article 7388


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!sol.ctr.columbia.edu!usc!rpi!psinntp!psinntp!pool!ujlh
From: ujlh@pool.info.sunyit.edu (James Henrickson)
Subject: Re: mktemp - Bus Error.
Message-ID: <1992Nov3.191433.26698@pool.info.sunyit.edu>
Organization: State University of New York -- Institute of Technology
References: <6607@otc.otca.oz> <1992Nov2.210351.12723@ee.ryerson.ca>
Date: Tue, 3 Nov 1992 19:14:33 GMT
Lines: 46

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.

Correct me if I am wrong, since this thread started a while ago.
I believe the original poster was referring to 386BSD, and the
above man description is not like the one I have for mktemp.  I
haven't used mktemp() in 386BSD yet but I have used mkstemp(),
which has the same man entry.  Under 386BSD, the six trailing X's
are not enforced.  I used four until I tried compiling on a Sun,
which required six.  I now use six for portability (like it really
matters since Ultrix doesn't support mkstemp!).  Maybe the portability
issue should be added to the man entry?

As pointed out by someone else, the problem was caused by using
a string constant (probably incorrect terminology, sorry all) as
the argument to the function call.  (I made the same mistake once!)

I hope this clears things up a little.

-- 
Jim H.
*
* James L. Henrickson  |  "I don't need a signature, I need a job!"
* ujlh@sunyit.edu      |  BSCS, December 1992