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

NAME

12       shmctl — XSI shared memory control operations
13

SYNOPSIS

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

DESCRIPTION

20       The shmctl() function operates on XSI shared memory (see the Base Defi‐
21       nitions  volume  of POSIX.1‐2017, Section 3.346, Shared Memory Object).
22       It is unspecified whether this function interoperates with the realtime
23       interprocess communication facilities defined in Section 2.8, Realtime.
24
25       The shmctl() function provides a variety of shared memory control oper‐
26       ations as specified by cmd.  The following values for  cmd  are  avail‐
27       able:
28
29       IPC_STAT    Place the current value of each member of the shmid_ds data
30                   structure associated with shmid into the structure  pointed
31                   to  by  buf.   The contents of the structure are defined in
32                   <sys/shm.h>.
33
34       IPC_SET     Set the value of the following members of the shmid_ds data
35                   structure  associated with shmid to the corresponding value
36                   found in the structure pointed to by buf:
37
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‐2017, Section 3.346, 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-2017, Standard for Information Technology -- Por‐
116       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
117       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
118       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
119       event of any discrepancy between this version and the original IEEE and
120       The Open Group Standard, the original IEEE and The Open Group  Standard
121       is  the  referee document. The original Standard can be obtained online
122       at http://www.opengroup.org/unix/online.html .
123
124       Any typographical or formatting errors that appear  in  this  page  are
125       most likely to have been introduced during the conversion of the source
126       files to man page format. To report such errors,  see  https://www.ker
127       nel.org/doc/man-pages/reporting_bugs.html .
128
129
130
131IEEE/The Open Group                  2017                           SHMCTL(3P)
Impressum