note 58382 added to ref.sem
| From: | DenisGerasimov at osu1 dot php dot net | Date: | Wed, 02 Nov 2005 12:19:01 +0000 |
| Subject: | note 58382 added to ref.sem | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-97979@lists.php.net to get a copy of this message | ||
Many (most?) developers use Win32 platform for PHP Web applications development while production
servers mostly run Unix/Linux OS. Below is the stub code I use to make it possible to write scripts
on Win32 that use semaphores:
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') { // if Windows OS detected
function ftok($pathname, $proj)
{
if (empty($pathname) || !file_exists($pathname)) { // an error occured
return -1;
}
$pathname = $pathname . (string) $proj;
$key = array();
while (sizeof($key) < strlen($pathname)) {
$key[] = ord(substr($pathname, sizeof($key), 1));
}
return dechex(array_sum($key));
}
function sem_acquire($sem_identifier)
{
return true;
}
function sem_get($key, $max_acquire = null, $perm = null, $auto_release = null)
{
return true;
}
function sem_release($sem_identifier)
{
return true;
}
function sem_remove($sem_identifier)
{
return true;
}
}
?>
Of course, there is no way to test semaphores until you have no Unix/Linux test server.
----
Manual Page -- http://www.php.net/manual/en/ref.sem.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58382
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58382&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58382&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58382&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58382&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58382&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58382&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58382&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58382&report=yes
Search -- http://master.php.net/manage/user-notes.php