1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "SHMCTL" 3P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" shmctl
.SH PROLOG
This manual page is part of the POSIX Programmer's Manual.
The Linux implementation of this interface may differ (consult
the corresponding Linux manual page for details of Linux behavior),
or the interface may not be implemented on Linux.
.SH NAME
shmctl \- XSI shared memory control operations
.SH SYNOPSIS
.LP
\fB#include <sys/shm.h>
.br
.sp
int shmctl(int\fP \fIshmid\fP\fB, int\fP \fIcmd\fP\fB, struct shmid_ds
*\fP\fIbuf\fP\fB); \fP
\fB
.br
\fP
.SH DESCRIPTION
.LP
The \fIshmctl\fP() function operates on XSI shared memory (see the
Base Definitions volume of IEEE\ Std\ 1003.1-2001,
Section 3.340, Shared Memory Object). It is unspecified whether this
function
interoperates with the realtime interprocess communication facilities
defined in \fIRealtime\fP .
.LP
The \fIshmctl\fP() function provides a variety of shared memory control
operations as specified by \fIcmd\fP. The following
values for \fIcmd\fP are available:
.TP 7
IPC_STAT
Place the current value of each member of the \fBshmid_ds\fP data
structure associated with \fIshmid\fP into the structure
pointed to by \fIbuf\fP. The contents of the structure are defined
in \fI<sys/shm.h>\fP.
.TP 7
IPC_SET
Set the value of the following members of the \fBshmid_ds\fP data
structure associated with \fIshmid\fP to the corresponding
value found in the structure pointed to by \fIbuf\fP:
.sp
.RS
.nf
\fBshm_perm.uid
shm_perm.gid
shm_perm.mode \fP Low-order nine bits.
.fi
.RE
.LP
IPC_SET can only be executed by a process that has an effective user
ID equal to either that of a process with appropriate
privileges or to the value of \fIshm_perm.cuid\fP or \fIshm_perm.uid\fP
in the \fBshmid_ds\fP data structure associated with
\fIshmid\fP.
.TP 7
IPC_RMID
Remove the shared memory identifier specified by \fIshmid\fP from
the system and destroy the shared memory segment and
\fBshmid_ds\fP data structure associated with it. IPC_RMID can only
be executed by a process that has an effective user ID equal
to either that of a process with appropriate privileges or to the
value of \fIshm_perm.cuid\fP or \fIshm_perm.uid\fP in the
\fBshmid_ds\fP data structure associated with \fIshmid\fP.
.sp
.SH RETURN VALUE
.LP
Upon successful completion, \fIshmctl\fP() shall return 0; otherwise,
it shall return -1 and set \fIerrno\fP to indicate the
error.
.SH ERRORS
.LP
The \fIshmctl\fP() function shall fail if:
.TP 7
.B EACCES
The argument \fIcmd\fP is equal to IPC_STAT and the calling process
does not have read permission; see \fIXSI Interprocess Communication\fP
\&.
.TP 7
.B EINVAL
The value of \fIshmid\fP is not a valid shared memory identifier,
or the value of \fIcmd\fP is not a valid command.
.TP 7
.B EPERM
The argument \fIcmd\fP is equal to IPC_RMID or IPC_SET and the effective
user ID of the calling process is not equal to that
of a process with appropriate privileges and it is not equal to the
value of \fIshm_perm.cuid\fP or \fIshm_perm.uid\fP in the
data structure associated with \fIshmid\fP.
.sp
.LP
The \fIshmctl\fP() function may fail if:
.TP 7
.B EOVERFLOW
The \fIcmd\fP argument is IPC_STAT and the \fIgid\fP or \fIuid\fP
value is too large to be stored in the structure pointed
to by the \fIbuf\fP argument.
.sp
.LP
\fIThe following sections are informative.\fP
.SH EXAMPLES
.LP
None.
.SH APPLICATION USAGE
.LP
The POSIX Realtime Extension defines alternative interfaces for interprocess
communication. Application developers who need to
use IPC should design their applications so that modules using the
IPC routines described in \fIXSI Interprocess Communication\fP can
be easily modified to use the alternative
interfaces.
.SH RATIONALE
.LP
None.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fIXSI Interprocess Communication\fP , \fIRealtime\fP , \fIshmat\fP()
, \fIshmdt\fP(), \fIshmget\fP(), \fIshm_open\fP(), \fIshm_unlink\fP()
, the Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI<sys/shm.h>\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
|