1SHMCTL(3P)                 POSIX Programmer's Manual                SHMCTL(3P)
2
3
4

PROLOG

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
11

NAME

13       shmctl — XSI shared memory control operations
14

SYNOPSIS

16       #include <sys/shm.h>
17
18       int shmctl(int shmid, int cmd, struct shmid_ds *buf);
19

DESCRIPTION

21       The shmctl() function operates on XSI shared memory (see the Base Defi‐
22       nitions  volume  of POSIX.1‐2008, Section 3.342, Shared Memory Object).
23       It is unspecified whether this function interoperates with the realtime
24       interprocess communication facilities defined in Section 2.8, 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  avail‐
28       able:
29
30       IPC_STAT    Place the current value of each member of the shmid_ds data
31                   structure associated with shmid into the structure  pointed
32                   to  by  buf.   The contents of the structure are defined in
33                   <sys/shm.h>.
34
35       IPC_SET     Set the value of the following members of the shmid_ds data
36                   structure  associated with shmid to the corresponding value
37                   found in the structure pointed to by buf:
38
39                       shm_perm.uid
40                       shm_perm.gid
41                       shm_perm.mode    Low-order nine bits.
42
43                   Also, the shm_ctime timestamp shall be set to  the  current
44                   time,  as  described in Section 2.7.1, IPC General Descrip‐
45                   tion.
46
47                   IPC_SET can only be executed  by  a  process  that  has  an
48                   effective  user  ID  equal to either that of a process with
49                   appropriate privileges or to the value of shm_perm.cuid  or
50                   shm_perm.uid in the shmid_ds data structure associated with
51                   shmid.
52
53       IPC_RMID    Remove the shared memory identifier specified by shmid from
54                   the  system  and  destroy  the  shared  memory  segment and
55                   shmid_ds data structure associated with  it.  IPC_RMID  can
56                   only be executed by a process that has an effective user ID
57                   equal to either that of a process with  appropriate  privi‐
58                   leges  or  to the value of shm_perm.cuid or shm_perm.uid in
59                   the shmid_ds data structure associated with shmid.
60

RETURN VALUE

62       Upon successful completion, shmctl()  shall  return  0;  otherwise,  it
63       shall return −1 and set errno to indicate the error.
64

ERRORS

66       The shmctl() function shall fail if:
67
68       EACCES The  argument  cmd  is equal to IPC_STAT and the calling process
69              does not have read permission; see Section 2.7, XSI Interprocess
70              Communication.
71
72       EINVAL The  value  of shmid is not a valid shared memory identifier, or
73              the value of cmd is not a valid command.
74
75       EPERM  The argument cmd is equal to IPC_RMID or IPC_SET and the  effec‐
76              tive  user  ID  of the calling process is not equal to that of a
77              process with appropriate privileges and it is not equal  to  the
78              value  of  shm_perm.cuid  or  shm_perm.uid in the data structure
79              associated with shmid.
80
81       The shmctl() function may fail if:
82
83       EOVERFLOW
84              The cmd argument is IPC_STAT and the gid or  uid  value  is  too
85              large  to be stored in the structure pointed to by the buf argu‐
86              ment.
87
88       The following sections are informative.
89

EXAMPLES

91       None.
92

APPLICATION USAGE

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 Section 2.7, XSI Interprocess Communication can be easily
98       modified to use the alternative interfaces.
99

RATIONALE

101       None.
102

FUTURE DIRECTIONS

104       None.
105

SEE ALSO

107       Section 2.7, XSI Interprocess  Communication,  Section  2.8,  Realtime,
108       shmat(), shmdt(), shmget(), shm_open(), shm_unlink()
109
110       The Base Definitions volume of POSIX.1‐2008, Section 3.342, Shared Mem‐
111       ory Object, <sys_shm.h>
112
114       Portions of this text are reprinted and reproduced in  electronic  form
115       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
116       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
117       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
118       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
119       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
120       event of any discrepancy between this version and the original IEEE and
121       The  Open Group Standard, the original IEEE and The Open Group Standard
122       is the referee document. The original Standard can be  obtained  online
123       at http://www.unix.org/online.html .
124
125       Any  typographical  or  formatting  errors that appear in this page are
126       most likely to have been introduced during the conversion of the source
127       files  to  man page format. To report such errors, see https://www.ker
128       nel.org/doc/man-pages/reporting_bugs.html .
129
130
131
132IEEE/The Open Group                  2013                           SHMCTL(3P)
Impressum