[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Puzzle - Temp file creation



Michael G Schwern <schwern@pobox.com> writes:

> On Wed, Jul 14, 1999 at 04:20:39PM -0400, Chaim Frenkel wrote:
> > >>>>> "MGS" == Michael G Schwern <schwern@pobox.com> writes:
> > MGS> open(TMP, ">foo".time.$$"); isn't even safe, because if your program
> > MGS> is running persistantly (say as a daemon or under mod_perl or FastCGI)
> > MGS> subsequent runs will have the same PID, and if it runs twice in the
> > MGS> same second (a strong possibility), you're screwed.
> > 
> > I still don't see the need for the search. Temporary files are
> > temporary, (duh).
> 
> Oh, right.  Temporary, deleted at the end of the program.  Right.

The *nix Way is often to open the temporary file, then unlink it.
That way it doesn't have a name, but you can still use it (as long as
you don't close it, and don't need to pass the name to another
program).  When the file is closed (e.g. automatically on program
exit), its storage is reclaimed.

-- 
Ariel Scolnicov        |"GCAAGAATTGAACTGTAG"            |ariels@compugen.co.il
Compugen Ltd.          |Tel: +972-2-6795059 (Jerusalem)	\  NEW IMPROVED URL!
72 Pinhas Rosen St.    |Tel: +972-3-7658520 (Main office)`--------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555  http://3w.compugen.co.il/~ariels

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe