>>>>> "MGS" == Michael G Schwern <schwern@pobox.com> writes: MGS> And several copies of that program are running at the same time (say MGS> its a CGI program on a high-load web server). What happens when two MGS> of them get run in the same second? Ooops. 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). If it is possible that the process is still alive when it gets around to stepping on its own foot, then a monotonically increasing counter would be perfect. If there is a race condition possible, split them up. I'm partial to mkdir "tempdir.$$". sticking hostname in there, if multiple hosts are sharing this. The pid can't be reused as long as the process is still around, so the kernel will take care of the locking. <chaim> -- Chaim Frenkel Nonlinear Knowledge, Inc. chaimf@pobox.com +1-718-236-0183 ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe