Log file with mkstemp() suffix or not? Re: r15435

Bill Nottingham notting at redhat.com
Thu Mar 4 16:00:16 EST 2010


Christian Stimming (stimming at tuhh.de) said: 
> Can someone explain to me the intention of the following code that
> initialiizes the trace file output file descriptor (from
> src/libqof/qof/qoflog.c:157ff)
> 
>   fname = g_strconcat(log_filename, ".XXXXXX", NULL);
>   if ((fd = g_mkstemp(fname)) != -1)
>   {
>       g_rename(fname, log_filename);
>       fout = fdopen(fd, "w");
>   }
> 
> where log_filename=="/tmp/gnucash.trace", so that fname will be
> something like "/tmp/gnucash.trace.KSHDJS". From reading the code, I
> guess it should mean "Open gnucash.trace.KSHDJS as trace file and
> immediately after opening it, rename it back into gnucash.trace".
> That's at least what the introduction of this code in
> http://svn.gnucash.org/trac/changeset/15435 suggests.

That's what's intended, yes. And it works for  me.

...
12566 open("/home/notting/tmp/gnucash.trace.RNY78U", O_RDWR|O_CREAT|O_EXCL,
0600) = 3
12566 rename("/home/notting/tmp/gnucash.trace.RNY78U",
"/home/notting/tmp/gnucash.trace") = 0
...

Bill


More information about the gnucash-devel mailing list