Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
shmctl(2)
Edit
PageHistory
Diff
Info
LikePages
SHMCTL !!!SHMCTL NAME SYNOPSIS DESCRIPTION SYSTEM CALLS RETURN VALUE ERRORS NOTE CONFORMING TO SEE ALSO ---- !!NAME shmctl - shared memory control !!SYNOPSIS __#include __ __#include __ __int shmctl(int__ ''shmid''__, int__ ''cmd''__, struct shmid_ds *__''buf''__);__ !!DESCRIPTION __shmctl()__ allows the user to receive information on a shared memory segment, set the owner, group, and permissions of a shared memory segment, or destroy a segment. The information about the segment identified by ''shmid'' is returned in a ''shmid_ds'' structure: struct shmid_ds { struct ipc_perm shm_perm; /* operation perms */ int shm_segsz; /* size of segment (bytes) */ time_t shm_atime; /* last attach time */ time_t shm_dtime; /* last detach time */ time_t shm_ctime; /* last change time */ unsigned short shm_cpid; /* pid of creator */ unsigned short shm_lpid; /* pid of last operator */ short shm_nattch; /* no. of current attaches */ /* the following are private */ unsigned short shm_npages; /* size of segment (pages) */ unsigned long *shm_pages; struct shm_desc *attaches; /* descriptors for attaches */ }; The fields in the member ''shm_perm'' can be set: struct ipc_perm { key_t key; __ ushort uid__; /* __owner__ euid and egid */ __ ushort gid__; ushort cuid; /* creator euid and egid */ ushort cgid; __ ushort mode__; /* lower 9 bits of access modes */ ushort seq; /* sequence number */ }; The following ''cmds'' are available: __IPC_STAT__ is used to copy the information about the shared memory segment into the buffer ''buf''. The user must have __read__ access to the shared memory segment. __IPC_SET__ is used to apply the changes the user has made to the ''uid'', ''gid'', or ''mode'' members of the ''shm_perms'' field. Only the lowest 9 bits of ''mode'' are used. The ''shm_ctime'' member is also updated. The user must be the owner, creator, or the super-user. __IPC_RMID__ is used to mark the segment as destroyed. It will actually be destroyed after the last detach. (I.e., when the ''shm_nattch'' member of the associated structure ''shmid_ds'' is zero.) The user must be the owner, creator, or the super-user. The user ''must'' ensure that a segment is eventually destroyed; otherwise its pages that were faulted in will remain in memory or swap. In addition, the __super-user__ can prevent or allow swapping of a shared memory segment with the following ''cmds'': (Linux only) __SHM_LOCK__ prevents swapping of a shared memory segment. The user must fault in any pages that are required to be present after locking is enabled. __SHM_UNLOCK__ allows the shared memory segment to be swapped out. The __IPC_INFO__, __SHM_STAT__ and __SHM_INFO__ control calls are used by the ipcs(8) program to provide information on allocated resources. In the future, these man be modified as needed or moved to a proc file system interface. !!SYSTEM CALLS __fork()__ After a __fork()__ the child inherits the attached shared memory segments. __exec()__ After an __exec()__ all attached shared memory segments are detached (not destroyed). __exit()__ Upon __exit()__ all attached shared memory segments are detached (not destroyed). !!RETURN VALUE 0 is returned on success, -1 on error. !!ERRORS On error, __errno__ will be set to one of the following: __EACCES__ is returned if __IPC_STAT__ is requested and ''shm_perm.modes'' does not allow read access for ''msqid''. __EFAULT__ The argument ''cmd'' has value __IPC_SET__ or __IPC_STAT__ but the address pointed to by ''buf'' isn't accessible. __EINVAL__ is returned if ''shmid'' is not a valid identifier, or ''cmd'' is not a valid command. __EIDRM__ is returned if ''shmid'' points to a removed identifier. __EPERM__ is returned if __IPC_SET__ or __IPC_RMID__ is attempted, and the user is not the creator, the owner, or the super-user, and the user does not have permission granted to their group or to the world. !!NOTE Various fields in a ''struct shmid_ds'' were shorts under Linux 2.2 and have become longs under Linux 2.4. To take advantage of this, a recompilation under glibc-2.1.91 or later should suffice. (The kernel distinguishes old and new calls by a IPC_64 flag in ''cmd''.) !!CONFORMING TO SVr4, SVID. SVr4 documents additional error conditions EINVAL, ENOENT, ENOSPC, ENOMEM, EEXIST. Neither SVr4 nor SVID documents an EIDRM error condition. !!SEE ALSO shmget(2), shmop(2) ----
7 pages link to
shmctl(2)
:
ipc(2)
Man2s
ipc(5)
shmat(2)
shmdt(2)
shmop(2)
shmget(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.