This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problem with database engine on Cygwin


> From: cygwin-owner at cygwin dot com [mailto:cygwin-owner at cygwin dot com]On Behalf
> Of dmay at tvi dot edu

> I worked around the issue in my code by closing the offending
> file, renaming
> it to a 20 character pseudo-random string and then deleting it.
> When I did
> that, I had no problem creating another file with the same name.
> The problem
> here is if I happen to get 2 20-character psuedo-random strings that are
> identical (not likely, I know), this is going to fail.
>
> So, I kludged it in a somewhat unclean, albeit functional, way.  Is there
> another workaround that is a little more elegant?


Might it be that this helps?

 $ man 3 mktemp


/Hannu E K Nevalainen, Mariefred, Sweden
--
I apologize that I didn't get a chance to respond to this right away.  I
inadvertently deleted it from my email before I could respond :o<

Anyway, I don't think you understand the issue here...Basically, mktemp
creates a temporary file that is unique for what exists in the directory now.
However, it does not and cannot guarantee to never create a temporary file
that has the same name as one that has been deleted by the current process.
That is the functionality I would really need to fix this problem, and mktemp
doesn't do that, unless it works very differently on Cygwin than it does
elsewhere.  Please see one of my previous posts with a small C program that
demonstrates this issue.

At any rate, I got an idea from this list to use a time stamp as part of the
file name, that way it would be guaranteed unique unless the time were
changed. That combined with the 20 character psuedo-random string gives me a
name that is sufficiently irreproduceable that I am comfortable it won't
happen under the same process (not in this universe, anyway :o).

Thanks for the input and ideas.
-- 
=================================
David May
Senior UNIX System Administrator
Albuquerque TVI
505-224-3015

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]