note 41936 added to function.tempnam
| From: | jhuiskam at NOuoguelphSPAM dot ca | Date: | Tue, 27 Apr 2004 03:46:26 +0000 |
| Subject: | note 41936 added to function.tempnam | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68850@lists.php.net to get a copy of this message | ||
In the code displayed below is the race condition really a problem, since the file will be opened
and truncated anyways?
Or would this be an acceptable solution?:
<?php
/* ... */
do{
$seed = substr(md5(microtime().posix_getpid()), 0, 8);
$filename = $dir . $trailing_slash . $prefix . $seed . $postfix;
} while (!($fp = fopen($filename, "x")));
fclose($fp);
return $filename;
/* ... */
?>
----
Manual Page -- http://www.php.net/manual/en/function.tempnam.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41936
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41936&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41936&report=yes
Search -- http://master.php.net/manage/user-notes.php