Re: shared memory access - shmod_open

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

 



I tried the php function chmod($sem, 0644) which works fine even if it
converts the octal number too, cf. xdebug trace file:

  0.0037      50280     -> chmod('/tmp/1521387531.sem', 420)
...myScripts/test.php:11
                           >=> TRUE
  0.0039      50280     -> shmop_open(2013277949, 'c', 420, 1)
...myScripts/test.php:15
                           >=> FALSE
 
So I think there must be something else wrong with my shmop_open. I also
tried shmop_open($sem_key, "c", "0644", 1) and shmop_open($sem_key, "c",
420, 1), which doesn´t work either. 

Thank you for your help,
Rolf.







Peter Ford-4 wrote:
> 
> Richard Lynch wrote:
>> On Thu, December 6, 2007 2:44 am, Rolf_ wrote:
>>> I have a problem working with shmop_open() in a Solaris environment.
>>> The
>>> following cli-script works fine, except shmod_open returns a warning
>>> 'unable
>>> to attach or create shared memory segment':
>>>
>>> <?php
>>> $sem = "/tmp/" . rand() . ".sem";
>>> touch ($sem);
>>> echo "sem $sem \n";
>>>
>>> $sem_key = ftok($sem, 'w');
>>> echo "sem_key $sem_key \n";
>>>
>>> if ($sem_key == -1) { die ("ftok error"); }
>>>
>>> $shm_id = shmop_open($sem_key, "w", 0644, 1);
>>> echo "shm_id $shm_id\n";
>>> ?>
>>>
>>> I checked the $sem_key with the Solaris ipcs command. The file exists
>>> and
>>> the read/write rights are correct. I tried explictly to call
>>> shmop_open with
>>> the right key - the error message remains the same.
>>>
>>> Checking out different access mode like "r" does not succeed too. In
>>> the
>>> Xdebug output, php changes the value 0644 to 420, i.e.
>>> shmop_open(1258300033, 'w', 420, 1). Of course, I compiled php with
>>> --enable-shmop.
>>>
>>> Does anyone has an idea what I might also check?
>> 
>> Perhaps the 0644 needs to be expressed in some other way?
>> 
>> I know it works fine that way for chmod and friends, so I wouldn't
>> expect it, but...
>> 
>> Or maybe 420 *IS* the right value, and you're on a red herring.
>> 
>> Try Googling for the error message and Solaris if you haven't done
>> that yet.
>> 
> 
> The problem is that 0644 == 420, because 0644 is parsed as "644 base 8"
> (the
> zero prefix forces the number to octal...)
> So 420 (decimal) is actually the correct value. RTFM for chmod, which
> gives you
> a big hint about this...
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/shared-memory-access---shmod_open-tp14188465p14278683.html
Sent from the PHP - General mailing list archive at Nabble.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux