Copyright (C) 2000-2012 |
Manpages SHMCTLSection: Linux Programmer's Manual (2)Updated: 2001-02-18 Index Return to Main Contents NAMEshmctl - shared memory controlSYNOPSIS#include <sys/ipc.h>#include <sys/shm.h> int shmctl(int shmid, int cmd, struct shmid_ds *buf); DESCRIPTIONshmctl() 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:
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)
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
RETURN VALUE0 is returned on success, -1 on error.ERRORSOn error, errno will be set to one of the following:
NOTEVarious 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 TOSVr4, SVID. SVr4 documents additional error conditions EINVAL, ENOENT, ENOSPC, ENOMEM, EEXIST. Neither SVr4 nor SVID documents an EIDRM error condition.SEE ALSOshmget(2), shmop(2)
IndexThis document was created by man2html, using the manual pages. Time: 02:08:15 GMT, January 21, 2025 |