|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-03-20 11:18 UTC] peter dot bridgman at dexdyne dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
Description: ------------ The actual php version is # php --version PHP 5.5.0-dev (cli) (built: Aug 24 2012 16:34:36) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies php was configured with: ./configure --enable-sysvsem --enable-sysvshm --enable-pcntl sem_acquire won't lock when a forked process acquires the semaphore. This behaviour is the same whether sem_get is called in every process or before the first pcntl_fork. It would seem sem_acquire treats forked processes as if they where the same process as the father, even if the got different pid. I also tryed this bug with $ php --version PHP 5.3.10-1ubuntu3.2 with Suhosin-Patch (cli) (built: Jun 13 2012 17:19:58) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies in $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 12.04.1 LTS Release: 12.04 Codename: precise whith exactly the same results. Thanks. Test script: --------------- <?php $pid = pcntl_fork(); if ($pid == -1) { die("could not fork 1"); } else if ($pid) { $pid = pcntl_fork(); if ($pid == -1) { die("could not fork 2"); } else if($pid) { $sem = sem_get('1234'); echo "father try acquire $sem\n"; $time = microtime(); sem_acquire($sem); echo "father acquired in ".($time-microtime())."\n"; } else { $sem = sem_get('1234'); echo "son 2 try acquire $sem\n"; $time=microtime(); sem_acquire($sem); echo "son 2 acquired in ".($time-microtime())."\n"; } } else { $sem = sem_get('1234'); echo "son 1 try acquire $sem\n"; $time=microtime(); sem_acquire($sem); echo "son 1 acquired in ".($time-microtime())."\n"; } ?> Expected result: ---------------- storage-tests:~ # php prueba.php father try acquire Resource id #4 father acquired in -4.6999999999964E-5 son 2 try acquire Resource id #4 son 1 try acquire Resource id #4 Actual result: -------------- storage-tests:~ # php prueba.php father try acquire Resource id #4 father acquired in -4.6999999999964E-5 son 2 try acquire Resource id #4 son 1 try acquire Resource id #4 son 2 acquired in -0.00010599999999999 son 1 acquired in -0.00010499999999997