1SHMCTL(P) POSIX Programmer's Manual SHMCTL(P)
2
3
4
6 shmctl - XSI shared memory control operations
7
9 #include <sys/shm.h>
10
11 int shmctl(int shmid, int cmd, struct shmid_ds *buf);
12
13
15 The shmctl() function operates on XSI shared memory (see the Base Defi‐
16 nitions volume of IEEE Std 1003.1-2001, Section 3.340, Shared Memory
17 Object). It is unspecified whether this function interoperates with the
18 realtime interprocess communication facilities defined in Realtime .
19
20 The shmctl() function provides a variety of shared memory control oper‐
21 ations as specified by cmd. The following values for cmd are available:
22
23 IPC_STAT
24 Place the current value of each member of the shmid_ds data
25 structure associated with shmid into the structure pointed to by
26 buf. The contents of the structure are defined in <sys/shm.h>.
27
28 IPC_SET
29 Set the value of the following members of the shmid_ds data
30 structure associated with shmid to the corresponding value found
31 in the structure pointed to by buf:
32
33
34 shm_perm.uid
35 shm_perm.gid
36 shm_perm.mode Low-order nine bits.
37
38 IPC_SET can only be executed by a process that has an effective user ID
39 equal to either that of a process with appropriate privileges or to the
40 value of shm_perm.cuid or shm_perm.uid in the shmid_ds data structure
41 associated with shmid.
42
43 IPC_RMID
44 Remove the shared memory identifier specified by shmid from the
45 system and destroy the shared memory segment and shmid_ds data
46 structure associated with it. IPC_RMID can only be executed by a
47 process that has an effective user ID equal to either that of a
48 process with appropriate privileges or to the value of
49 shm_perm.cuid or shm_perm.uid in the shmid_ds data structure
50 associated with shmid.
51
52
54 Upon successful completion, shmctl() shall return 0; otherwise, it
55 shall return -1 and set errno to indicate the error.
56
58 The shmctl() function shall fail if:
59
60 EACCES The argument cmd is equal to IPC_STAT and the calling process
61 does not have read permission; see XSI Interprocess Communica‐
62 tion .
63
64 EINVAL The value of shmid is not a valid shared memory identifier, or
65 the value of cmd is not a valid command.
66
67 EPERM The argument cmd is equal to IPC_RMID or IPC_SET and the effec‐
68 tive user ID of the calling process is not equal to that of a
69 process with appropriate privileges and it is not equal to the
70 value of shm_perm.cuid or shm_perm.uid in the data structure
71 associated with shmid.
72
73
74 The shmctl() function may fail if:
75
76 EOVERFLOW
77 The cmd argument is IPC_STAT and the gid or uid value is too
78 large to be stored in the structure pointed to by the buf argu‐
79 ment.
80
81
82 The following sections are informative.
83
85 None.
86
88 The POSIX Realtime Extension defines alternative interfaces for inter‐
89 process communication. Application developers who need to use IPC
90 should design their applications so that modules using the IPC routines
91 described in XSI Interprocess Communication can be easily modified to
92 use the alternative interfaces.
93
95 None.
96
98 None.
99
101 XSI Interprocess Communication , Realtime , shmat() , shmdt() ,
102 shmget() , shm_open() , shm_unlink() , the Base Definitions volume of
103 IEEE Std 1003.1-2001, <sys/shm.h>
104
106 Portions of this text are reprinted and reproduced in electronic form
107 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
108 -- Portable Operating System Interface (POSIX), The Open Group Base
109 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
110 Electrical and Electronics Engineers, Inc and The Open Group. In the
111 event of any discrepancy between this version and the original IEEE and
112 The Open Group Standard, the original IEEE and The Open Group Standard
113 is the referee document. The original Standard can be obtained online
114 at http://www.opengroup.org/unix/online.html .
115
116
117
118IEEE/The Open Group 2003 SHMCTL(P)