Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

shmop_open(3) [php man page]

SHMOP_OPEN(3)								 1							     SHMOP_OPEN(3)

shmop_open - Create or open shared memory block

SYNOPSIS
int shmop_open (int $key, string $flags, int $mode, int $size) DESCRIPTION
shmop_open(3) can create or open a shared memory block. PARAMETERS
o $key - System's id for the shared memory block. Can be passed as a decimal or hex. o $flags - The flags that you can use: o "a" for access (sets SHM_RDONLY for shmat) use this flag when you need to open an existing shared memory segment for read only o "c" for create (sets IPC_CREATE) use this flag when you need to create a new shared memory segment or if a segment with the same key exists, try to open it for read and write o "w" for read & write access use this flag when you need to read and write to a shared memory segment, use this flag in most cases. o "n" create a new memory segment (sets IPC_CREATE|IPC_EXCL) use this flag when you want to create a new shared memory seg- ment but if one already exists with the same flag, fail. This is useful for security purposes, using this you can prevent race condition exploits. o $mode - The permissions that you wish to assign to your memory segment, those are the same as permission for a file. Permissions need to be passed in octal form, like for example 0644 o $size - The size of the shared memory block you wish to create in bytes Note Note: the 3rd and 4th should be entered as 0 if you are opening an existing memory segment. RETURN VALUES
On success shmop_open(3) will return an id that you can use to access the shared memory segment you've created. FALSE is returned on failure. EXAMPLES
Example #1 Create a new shared memory block <?php $shm_key = ftok(__FILE__, 't'); $shm_id = shmop_open($shm_key, "c", 0644, 100); ?> This example opened a shared memory block with a system id returned by ftok(3). SEE ALSO
shmop_close(3), shmop_delete(3). PHP Documentation Group SHMOP_OPEN(3)

Check Out this Related Man Page

SHMGET(2)						      BSD System Calls Manual							 SHMGET(2)

NAME
shmget -- obtain a shared memory identifier LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> int shmget(key_t key, size_t size, int flag); DESCRIPTION
Based on the values of key and flag, shmget() returns the identifier of a newly created or previously existing shared memory segment. The key is analogous to a filename: it provides a handle that names an IPC object. There are three ways to specify a key: o IPC_PRIVATE may be specified, in which case a new IPC object will be created. o An integer constant may be specified. If no IPC object corresponding to key is specified and the IPC_CREAT bit is set in flag, a new one will be created. o The ftok(3) may be used to generate a key from a pathname. The mode of a newly created IPC object is determined by OR'ing the following constants into the flag argument: S_IRUSR Read access for owner. S_IWUSR Write access for owner. S_IRGRP Read access for group. S_IWGRP Write access for group. S_IROTH Read access for other. S_IWOTH Write access for other. When creating a new shared memory segment, size indicates the desired size of the new segment in bytes. The size of the segment may be rounded up to a multiple convenient to the kernel (i.e., the page size). RETURN VALUES
Upon successful completion, shmget() returns the positive integer identifier of a shared memory segment. Otherwise, -1 is returned and errno set to indicate the error. ERRORS
The shmget() system call will fail if: [EINVAL] Size specified is greater than the size of the previously existing segment. Size specified is less than the system imposed minimum, or greater than the system imposed maximum. [ENOENT] No shared memory segment was found matching key, and IPC_CREAT was not specified. [ENOSPC] The kernel was unable to allocate enough memory to satisfy the request. [EEXIST] IPC_CREAT and IPC_EXCL were specified, and a shared memory segment corresponding to key already exists. SEE ALSO
shmat(2), shmctl(2), shmdt(2), stat(2), ftok(3) BSD
December 17, 2010 BSD
Man Page