*BSD News Article 7341


Return to BSD News archive

Newsgroups: comp.unix.bsd
Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!fcom.cc.utah.edu!cs.weber.edu!terry
From: terry@cs.weber.edu (A Wizard of Earth C)
Subject: Re: mktemp - Bus Error.
Message-ID: <1992Nov3.031257.11305@fcom.cc.utah.edu>
Sender: news@fcom.cc.utah.edu
Organization: University of Utah Computer Center
References: <6607@otc.otca.oz> <1992Nov2.210351.12723@ee.ryerson.ca>
Date: Tue, 3 Nov 92 03:12:57 GMT
Lines: 44

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.

The problem is that the compiler saves off "XXXX" in a non-modifiable area;
one would think that the prototype would would ensure that this couldn't
happen -- one of the supposed "benefits" of ANSI-C.

Once this is resolved, you'd probably want to change it to "XXXXXX" so it will
actually work, since it's supposed to be six X's.


					Terry Lambert
					terry@icarus.weber.edu
					terry_lambert@novell.com
---
Any opinions in this posting are my own and not those of my present
or previous employers.
-- 
-------------------------------------------------------------------------------
                                        "I have an 8 user poetic license" - me
 Get the 386bsd FAQ from agate.berkeley.edu:/pub/386BSD/386bsd-0.1/unofficial
-------------------------------------------------------------------------------