#include <sys/shm.h> int shmctl(int shmid, int cmd, struct shmid_ds *buf);
|
The shmctl() function provides shared memory control operations as specified by cmd on the shared memory segment specified by shmid.
Parameters
The cmd parameter can have one of the following values:
IPC_SET can be performed only by a thread with appropriate privileges or one that has an effective user ID equal to the value of shm_perm.cuid or shm_perm.uid in the shmid_ds data structure associated with shmid.
If a shared memory segment is resized to a smaller size, other threads using the shared memory that is being removed from the shared memory segment may experience memory exceptions when accessing that memory.
Authorities
Figure 1-15. Authorization Required for shmctl()
| Object Referred to | Authority Required | errno |
|---|---|---|
| Shared memory segment for which state information is retrieved (cmd = IPC_STAT) | Read | EACCES |
| Shared memory segment for which state information is set (cmd = IPC_SET) | See Note | EPERM |
| Shared memory segment to be removed (cmd = IPC_RMID) | See Note | EPERM |
| Shared memory segment to be resized (cmd = SHM_SIZE) | See Note | EPERM |
| Note: To set shared memory segment information, to remove a shared memory segment, or to resize a shared memory segment, the thread must be the owner or creator of the shared memory segment or have appropriate privileges. |
Return Value
Error Conditions
If shmctl() is not successful, errno usually indicates one of the following errors. Under some conditions, errno could indicate an error other than those listed here.
An attempt was made to access an object in a way forbidden by its object access permissions.
The thread does not have access to the specified file, directory, component, or path.
The parameter cmd is equal to IPC_STAT and the calling thread does not have read permission.
The value of shmid corresponds to a shared memory ID that has been marked as damaged by a previous shared memory operation.
In attempting to use an argument in a call, the system detected an address that is not valid.
While attempting to access a parameter passed to this function, the system detected an address that is not valid.
A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.
An argument value is not valid, out of range, or NULL.
One of the following has occurred:
A function needed to allocate storage, but no storage is available.
A shared memory identifier segment is to be resized, but the amount of available physical memory is not sufficient to fulfill the request.
You must have appropriate privileges or be the owner of the object or other resource to do the requested operation.
The parameter cmd is equal to IPC_RMID or IPC_SET and both of the following are true:
The operation failed because of an unknown system state. See any messages in the job log and correct any errors that are indicated, then retry the operation.
Error Messages
None.
Usage Notes
Related Information
Example
For an example of using this function, see Using Semaphores and Shared Memory in Appendix A, Examples.
| Top | Interprocess Communication APIs | APIs by category |
| [Information Center Home Page | Feedback ] | [Legal | AS/400 Glossary] |