Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is intended. It returns an id that you can use in PHP to access the shared memory block. It is a shmop resource as you can see here: <a href="http://php.net/manual/en/resource.php" rel="nofollow">http://php.net/manual/en/resource.php</a></p> <p>To figure out which one it is, use your own key instead of 0. I wrote up a quick example:</p> <pre><code>&lt;?php echo "Opening shared memory!\n"; if($shm_id = shmop_open(0xdeadbeef, 'c', 0666, 1024)) { echo "Opened shared memory\n"; echo "Wrote " . shmop_write($shm_id, "Testing", 0) . " bytes.\n"; echo shmop_read($shm_id, 0, 7) . "\n"; var_dump($shm_id); echo $shm_id . "\n"; $line = `ipcs -m |grep deadbeef`; list($null, $shmid, $null) = explode(' ', $line); echo "shmid is: " . $shmid . "\n"; } ?&gt; </code></pre> <p>Output:</p> <blockquote> <p>Opening shared memory! Opened shared memory Wrote 7 bytes. Testing int(4) 4 shmid is: 1533149226</p> </blockquote> <p>And as you can see, it is easy to find:</p> <blockquote> <pre><code>[nedwidek@yule ~]$ ipcs -m |grep deadbeef 0xdeadbeef 1533149226 nedwidek 666 1024 0 </code></pre> </blockquote> <p>Just an update on what I've pursued:</p> <p>From php-src/ext/shmop/shmop.c (<a href="https://github.com/php/php-src/blob/master/ext/shmop/shmop.c" rel="nofollow">https://github.com/php/php-src/blob/master/ext/shmop/shmop.c</a>)</p> <pre><code>rsid = zend_list_insert(shmop, shm_type TSRMLS_CC); RETURN_LONG(rsid); </code></pre> <p>Two things here.... Validates that you get a resource id back and the shmop struct is persisted. This means that shmod->shmid can be obtained.</p> <p>I've also subscribed to the internals mailing list. I'll be posting a query on why they don't allow you to get the shmid, if a function were introduced to get it (or maybe the shmop details as a hash array) would they merge a patch for this.</p> <p>Let me know what your interest level is in any of this (collaborate on a patch, receive any patch I come up with, wait for PHP to officially integrate (if ever), or none). If you're not interested at all, I'll stop updating my answer. -- Regards Erik.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload