× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




The code for the IFS version of tmpnam() uses both the current job number
and the current clock (timestamp) to generate a unique filename. Once the
name is generated, the code uses stat() to make sure a filename does not
already exist with that name. If the file already exists, it will generate
another name. The name generated by tmpnam() is unique to the system at
time of generation.

It is possible for a collision to occur with the filename such that the
same filename is generated twice. The caller of the tmpnam() routine
should test that some other process has not created an equivalently named
file in the lag time between name generation and file creation. Some
applications can use the tmpfile() function to avoid this issue.

Your solution of adding the job number as a prefix/suffix should work well
and avoid any potential issues.

Scott Hanson

message: 5
date: Tue, 14 Oct 2014 13:19:57 +0000
from: "McGovern, Sean" <Sean.McGovern@xxxxxxxxxxxx>
subject: tmpnam() not unique

I've believe I have encountered an issue with my use of tmpnam().

If 2 jobs use tmpnam() at the same timestamp moment, I *think* the
same filename is returned (though I don't know how to test this
scenario).

I haven't coded to handle this possibility, and end up with two jobs
trying to create the same temporary IFS file.

I was thinking that a solution could be just prefix/suffix the job
number to the filename returned by tmpnam().

Does that seem like a feasible solution ?

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.