*BSD News Article 7116


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!agate!ames!sun-barr!rutgers!twwells!bill
From: bill@twwells.com (T. William Wells)
Newsgroups: comp.unix.bsd
Subject: Re: mktemp - Bus Error.
Message-ID: <Bws3sp.1Fv@twwells.com>
Date: 27 Oct 92 11:55:34 GMT
References: <6607@otc.otca.oz> <1992Oct26.233341.19917@zip.eecs.umich.edu>
Organization: None, Mt. Laurel, NJ
Lines: 24

In article <1992Oct26.233341.19917@zip.eecs.umich.edu> dmuntz@quip.eecs.umich.edu (Daniel A Muntz) 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?
:
: Yes.  Compile with -traditional: 'cc -traditional foo.c'
: I suppose someone could "fix" mktemp...

Mktemp is defined to modify its argument....and C strings are not
required to be modifiable. The proper usage of mktemp is to
create an array, e.g. char foo[] = "/tmp/XXXXXX", and then call
mktemp(foo).

---
Bill                            { rutgers | decwrl | telesci }!twwells!bill
bill@twwells.com