This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: mkstemp bug
- From: "Tony Richardson" <richardson at evansville dot edu>
- To: cygwin at cygwin dot com
- Date: Wed, 27 Apr 2005 12:41:20 -0500
- Subject: Re: mkstemp bug
- References: <usm1cb0aa.fsf@gnu.org>
I'm surprised your example doesn't segfault. My Linux man page
says explicitly that the template should not be a string constant
but must be a character array, i.e. use
char t1[] = "/tmp/clisp-x-io-XXXXXX";
char t2[] = "/tmp/clisp-x-io-XXXXXX";
char t3[] = "/tmp/clisp-x-io-XXXXXX";
mkstemp(t1);
mkstemp(t2);
mkstemp(t3);
instead.
Tony Richardson
p.s. Don't use
char *t1 = "/tmp/clisp-x-io-XXXXXX";
either. It's not the same. Constant strings like this and in your
original program can be stored in a read-only segment and so
are not necessarily writeable.
"Sam Steingold" wrote:
> Hi,
> it appears that mkstemp() returns a temp FD pointing to the same file:
> mkstemp ("/tmp/clisp-x-io-XXXXXX");
> ==> "/tmp/clisp-x-io-000592"
> mkstemp ("/tmp/clisp-x-io-XXXXXX");
> ==> "/tmp/clisp-x-io-000592"
> mkstemp ("/tmp/clisp-x-io-XXXXXX");
> ==> "/tmp/clisp-x-io-000592"
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/