Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

shmctl, shmctl64 - shared memory control operations

&pagelevel(4)&pagelevel

Syntax

#include <sys/shm.h>

int shmctl(int shmid, int cmd, struct shmid_ds *buf); 

CRTE111A30

int shmctl64(int shmid, int cmd, struct shmid_ds64 *buf); (End)

Description

shmctl() provides a number of shared memory control operations, as specified by cmd.

The function shmctl64() behaves like the function shmctl(), except that it uses a shmid_ds64 structure instead of a shmid_ds structure for the cmd values IPC_STAT and IPC_SET and therefore will work correctly after 01/19/2038 03:14:07 UTC.

The shmid_ds contains the following elements:

struct ipc_perm shm_perm;       /* operation permission struct */
int             shm_segsz;      /* size of segment in bytes */
ulong_t        *shm_shmat;      /* hidden */
ushort_t        shm_dummy;      /* shm_lkcnt - no longer used! */
pid_t           shm_lpid;       /* pid of last shmop */
pid_t           shm_cpid;       /* pid of creator */
ulong_t         shm_nattch;     /* used only for shminfo */
ulong_t         shm_cnattch;    /* used only for shminfo */
time_t          shm_atime;      /* last shmat time */
time_t          shm_dtime;      /* last shmdt time */
time_t          shm_ctime;      /* last change time */

The elements of the structure shmid_ds64 structure are defined like the shmid_ds structure except for the following components:

time64_t        shm_atime;
time64_t        shm_dtime;
time64_t        shm_ctime;


The following values for cmd are available:

 

IPC_STAT

Enter the current values of all members of the shmid_ds resp. shmid_ds64 data structure associated with shmid into the structure pointed to by buf. The format of the structure is defined in sys/shm.h.

 

IPC_SET

Set the values of the following members of the shmid_ds resp. shmid_ds64 data structure associated with shmid to the corresponding values from the structure pointed to by buf:

shm_perm.uid
shm_perm.gid
shm_perm.mode    /* only the low-order 9 bits */

IPC_SET can only be executed by a process that has an effective user ID equal to that of a process with appropriate privileges or to the value of shm_perm.cuid or shm_perm.uid in the shmid_ds resp. shmid_ds64 data structure associated with shmid.

 

IPC_RMID

Remove the shared memory identifier specified by shmid from the system as well as the shared memory segment and the shmid_ds resp. shmid_ds64 data structure associated with it. IPC_RMID can only be executed by a process that has an effective user ID equal to that of a process with appropriate privileges or to the value of shm_perm.cuid or shm_perm.uid in the shmid_ds resp. shmid_ds64 data structure associated with shmid.

Return val.

0

if successful.


-1

if an error occurs. errno is set to indicate the error.

Errors

shmctl() and shmctl64() will fail if: 

 

EACCES

cmd is equal to IPC_STAT and the calling process does not have read permission.

 

Extension

 

EFAULT

msgp points to an invalid address. (End)

 

EINVAL

The value of shmid is not a valid shared memory identifier, or
the value of cmd is not a valid command, or
cmd is IPC_SET and shm_perm.uid or shm_perm.gid is invalid.

 

Extension 

 

ENOMEM

Not enough memory is available.

 

EPERM

cmd is equal to IPC_RMID or IPC_SET and the effective user ID of the calling process is not equal to that of a process with appropriate privileges and it is not equal to the value of shm_perm.cuid or shm_perm.uid in the data structure associated with shmid.


shmctl() will fail if: 
Extension

 

EOVERFLOW

cmd is equal to IPC_SET and a timestamp is too large for a time-t component (this will happen after 01/19/2038 03:14:07 a.m. UTC)(End)


shmctl64() will fail if:

 

EINVAL

POSIX-BC correction status < A47.

See also

shmat(), shmdt(), shmget(), sys/shm.h, section “Interprocess communication”.