php man page for shm_attach

Query: shm_attach

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

SHM_ATTACH(3)								 1							     SHM_ATTACH(3)

shm_attach - Creates or open a shared memory segment

SYNOPSIS
resource shm_attach (int $key, [int $memsize], [int $perm = 0666])
DESCRIPTION
shm_attach(3) returns an id that can be used to access the System V shared memory with the given $key, the first call creates the shared memory segment with $memsize and the optional perm-bits $perm. A second call to shm_attach(3) for the same $key will return a different shared memory identifier, but both identifiers access the same underlying shared memory. $memsize and $perm will be ignored.
PARAMETERS
o $key - A numeric shared memory segment ID o $memsize - The memory size. If not provided, default to the sysvshm.init_mem in the php.ini, otherwise 10000 bytes. o $perm - The optional permission bits. Default to 0666.
RETURN VALUES
Returns a shared memory segment identifier.
CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | This function now returns a resource instead of | | | an integer. | | | | +--------+---------------------------------------------------+
NOTES
Note This function used to return an integer value prior to PHP 5.3.0. To achieve the same value in a portable manner, the return value can be cast to an integer like: Example #1 <?php // Create a temporary file and return its path $tmp = tempnam('/tmp', 'PHP'); // Get the file token key $key = ftok($tmp, 'a'); // Attach the SHM resource, notice the cast afterwards $id = shm_attach($key); if ($id === false) { die('Unable to create the shared memory segment'); } // Cast to integer, since prior to PHP 5.3.0 the resource id // is returned which can be exposed when casting a resource // to an integer $id = (integer) $id; ?>
SEE ALSO
shm_detach(3), ftok(3). PHP Documentation Group SHM_ATTACH(3)
Related Man Pages
shmget(2) - sunos
shmat(2) - opendarwin
shmget(2) - opendarwin
shmget(2) - netbsd
shm_attach(3) - php
Similar Topics in the Unix Linux Community
perm bits
Aigaion Bibliography System 2.0.0 beta (Default branch)
Aigaion Bibliography System 2.0.2 beta (Default branch)
Trying to implement shared memory
How to interpret the shared memory key