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