|
message: 4
date: Tue, 14 Oct 2014 14:52:21 +0000
from: "McGovern, Sean" <Sean.McGovern@xxxxxxxxxxxx>
subject: RE: tmpnam() not unique
Thanks Scott.
You say tmpnam() already uses current job number but it is still
possible for a collision to occur (with another job) ?
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of
Scott Hanson
Sent: 14 October 2014 15:40
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: tmpnam() not unique
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: 5scenario).
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
--
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 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.