man-pages/man2/shmctl.2.html
2021-03-31 01:06:50 +01:00

597 lines
17 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SHMCTL</TITLE>
</HEAD><BODY>
<H1>SHMCTL</H1>
Section: Linux Programmer's Manual (2)<BR>Updated: 2019-08-02<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
shmctl - System V shared memory control
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>#include &lt;<A HREF="file:///usr/include/sys/ipc.h">sys/ipc.h</A>&gt;</B>
<BR>
<B>#include &lt;<A HREF="file:///usr/include/sys/shm.h">sys/shm.h</A>&gt;</B>
<P>
<B>int shmctl(int </B><I>shmid</I><B>, int </B><I>cmd</I><B>, struct shmid_ds *</B><I>buf</I><B>);</B>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>shmctl</B>()
performs the control operation specified by
<I>cmd</I>
on the System&nbsp;V shared memory segment whose identifier is given in
<I>shmid</I>.
<P>
The
<I>buf</I>
argument is a pointer to a <I>shmid_ds</I> structure,
defined in <I>&lt;<A HREF="file:///usr/include/sys/shm.h">sys/shm.h</A>&gt;</I> as follows:
<P>
struct shmid_ds {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;struct&nbsp;ipc_perm&nbsp;shm_perm;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Ownership&nbsp;and&nbsp;permissions&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;size_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shm_segsz;&nbsp;&nbsp;&nbsp;/*&nbsp;Size&nbsp;of&nbsp;segment&nbsp;(bytes)&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;time_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shm_atime;&nbsp;&nbsp;&nbsp;/*&nbsp;Last&nbsp;attach&nbsp;time&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;time_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shm_dtime;&nbsp;&nbsp;&nbsp;/*&nbsp;Last&nbsp;detach&nbsp;time&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;time_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shm_ctime;&nbsp;&nbsp;&nbsp;/*&nbsp;Last&nbsp;change&nbsp;time&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;pid_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shm_cpid;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;PID&nbsp;of&nbsp;creator&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;pid_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shm_lpid;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;PID&nbsp;of&nbsp;last&nbsp;<A HREF="/cgi-bin/man/man2html?2+shmat">shmat</A>(2)/<A HREF="/cgi-bin/man/man2html?2+shmdt">shmdt</A>(2)&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;shmatt_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shm_nattch;&nbsp;&nbsp;/*&nbsp;No.&nbsp;of&nbsp;current&nbsp;attaches&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;...
};
<P>
The
<I>ipc_perm</I>
structure is defined as follows
(the highlighted fields are settable using
<B>IPC_SET</B>):
<P>
struct ipc_perm {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;key_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;__key;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Key&nbsp;supplied&nbsp;to&nbsp;<A HREF="/cgi-bin/man/man2html?2+shmget">shmget</A>(2)&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;uid_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>uid</B>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Effective&nbsp;UID&nbsp;of&nbsp;owner&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;gid_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>gid</B>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Effective&nbsp;GID&nbsp;of&nbsp;owner&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;uid_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cuid;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Effective&nbsp;UID&nbsp;of&nbsp;creator&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;gid_t&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cgid;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Effective&nbsp;GID&nbsp;of&nbsp;creator&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;short&nbsp;<B>mode</B>;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;<B>Permissions</B>&nbsp;+&nbsp;SHM_DEST&nbsp;and
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SHM_LOCKED&nbsp;flags&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;short&nbsp;__seq;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Sequence&nbsp;number&nbsp;*/
};
<P>
Valid values for
<I>cmd</I>
are:
<DL COMPACT>
<DT id="1"><B>IPC_STAT</B>
<DD>
Copy information from the kernel data structure associated with
<I>shmid</I>
into the
<I>shmid_ds</I>
structure pointed to by <I>buf</I>.
The caller must have read permission on the
shared memory segment.
<DT id="2"><B>IPC_SET</B>
<DD>
Write the values of some members of the
<I>shmid_ds</I>
structure pointed to by
<I>buf</I>
to the kernel data structure associated with this shared memory segment,
updating also its
<I>shm_ctime</I>
member.
The following fields can be changed:
<I>shm_perm.uid</I>, <I>shm_perm.gid</I>,
and (the least significant 9 bits of) <I>shm_perm.mode</I>.
The effective UID of the calling process must match the owner
(<I>shm_perm.uid</I>)
or creator
(<I>shm_perm.cuid</I>)
of the shared memory segment, or the caller must be privileged.
<DT id="3"><B>IPC_RMID</B>
<DD>
Mark the segment to be destroyed.
The segment will actually be destroyed
only after the last process detaches it (i.e., when the
<I>shm_nattch</I>
member of the associated structure
<I>shmid_ds</I>
is zero).
The caller must be the owner or creator of the segment, or be privileged.
The
<I>buf</I>
argument is ignored.
<DT id="4"><DD>
If a segment has been marked for destruction, then the (nonstandard)
<B>SHM_DEST</B>
flag of the
<I>shm_perm.mode</I>
field in the associated data structure retrieved by
<B>IPC_STAT</B>
will be set.
<DT id="5"><DD>
The caller <I>must</I> ensure that a segment is eventually destroyed;
otherwise its pages that were faulted in will remain in memory or swap.
<DT id="6"><DD>
See also the description of
<I>/proc/sys/kernel/shm_rmid_forced</I>
in
<B><A HREF="/cgi-bin/man/man2html?5+proc">proc</A></B>(5).
<DT id="7"><B>IPC_INFO</B> (Linux-specific)
<DD>
Return information about system-wide shared memory limits and
parameters in the structure pointed to by
<I>buf</I>.
This structure is of type
<I>shminfo</I>
(thus, a cast is required),
defined in
<I>&lt;<A HREF="file:///usr/include/sys/shm.h">sys/shm.h</A>&gt;</I>
if the
<B>_GNU_SOURCE</B>
feature test macro is defined:
<DT id="8"><DD>
struct shminfo {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;shmmax;&nbsp;/*&nbsp;Maximum&nbsp;segment&nbsp;size&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;shmmin;&nbsp;/*&nbsp;Minimum&nbsp;segment&nbsp;size;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;always&nbsp;1&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;shmmni;&nbsp;/*&nbsp;Maximum&nbsp;number&nbsp;of&nbsp;segments&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;shmseg;&nbsp;/*&nbsp;Maximum&nbsp;number&nbsp;of&nbsp;segments
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;that&nbsp;a&nbsp;process&nbsp;can&nbsp;attach;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unused&nbsp;within&nbsp;kernel&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;shmall;&nbsp;/*&nbsp;Maximum&nbsp;number&nbsp;of&nbsp;pages&nbsp;of
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shared&nbsp;memory,&nbsp;system-wide&nbsp;*/
};
<DT id="9"><DD>
The
<I>shmmni</I>,
<I>shmmax</I>,
and
<I>shmall</I>
settings can be changed via
<I>/proc</I>
files of the same name; see
<B><A HREF="/cgi-bin/man/man2html?5+proc">proc</A></B>(5)
for details.
<DT id="10"><B>SHM_INFO</B> (Linux-specific)
<DD>
Return a
<I>shm_info</I>
structure whose fields contain information
about system resources consumed by shared memory.
This structure is defined in
<I>&lt;<A HREF="file:///usr/include/sys/shm.h">sys/shm.h</A>&gt;</I>
if the
<B>_GNU_SOURCE</B>
feature test macro is defined:
<DT id="11"><DD>
struct shm_info {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used_ids;&nbsp;/*&nbsp;#&nbsp;of&nbsp;currently&nbsp;existing
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;segments&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;shm_tot;&nbsp;&nbsp;/*&nbsp;Total&nbsp;number&nbsp;of&nbsp;shared
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memory&nbsp;pages&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;shm_rss;&nbsp;&nbsp;/*&nbsp;#&nbsp;of&nbsp;resident&nbsp;shared
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memory&nbsp;pages&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;shm_swp;&nbsp;&nbsp;/*&nbsp;#&nbsp;of&nbsp;swapped&nbsp;shared
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;memory&nbsp;pages&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;swap_attempts;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Unused&nbsp;since&nbsp;Linux&nbsp;2.4&nbsp;*/
<BR>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;long&nbsp;swap_successes;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Unused&nbsp;since&nbsp;Linux&nbsp;2.4&nbsp;*/
};
<DT id="12"><B>SHM_STAT</B> (Linux-specific)
<DD>
Return a
<I>shmid_ds</I>
structure as for
<B>IPC_STAT</B>.
However, the
<I>shmid</I>
argument is not a segment identifier, but instead an index into
the kernel's internal array that maintains information about
all shared memory segments on the system.
<DT id="13"><B>SHM_STAT_ANY</B> (Linux-specific, since Linux 4.17)
<DD>
Return a
<I>shmid_ds</I>
structure as for
<B>SHM_STAT</B>.
However,
<I>shm_perm.mode</I>
is not checked for read access for
<I>shmid</I>,
meaning that any user can employ this operation (just as any user may read
<I>/proc/sysvipc/shm</I>
to obtain the same information).
</DL>
<P>
The caller can prevent or allow swapping of a shared
memory segment with the following <I>cmd</I> values:
<DL COMPACT>
<DT id="14"><B>SHM_LOCK</B> (Linux-specific)
<DD>
Prevent swapping of the shared memory segment.
The caller must fault in
any pages that are required to be present after locking is enabled.
If a segment has been locked, then the (nonstandard)
<B>SHM_LOCKED</B>
flag of the
<I>shm_perm.mode</I>
field in the associated data structure retrieved by
<B>IPC_STAT</B>
will be set.
<DT id="15"><B>SHM_UNLOCK</B> (Linux-specific)
<DD>
Unlock the segment, allowing it to be swapped out.
</DL>
<P>
In kernels before 2.6.10, only a privileged process
could employ
<B>SHM_LOCK</B>
and
<B>SHM_UNLOCK</B>.
Since kernel 2.6.10, an unprivileged process can employ these operations
if its effective UID matches the owner or creator UID of the segment, and
(for
<B>SHM_LOCK</B>)
the amount of memory to be locked falls within the
<B>RLIMIT_MEMLOCK</B>
resource limit (see
<B><A HREF="/cgi-bin/man/man2html?2+setrlimit">setrlimit</A></B>(2)).
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
A successful
<B>IPC_INFO</B>
or
<B>SHM_INFO</B>
operation returns the index of the highest used entry in the
kernel's internal array recording information about all
shared memory segments.
(This information can be used with repeated
<B>SHM_STAT</B>
or
<B>SHM_STAT_ANY</B>
operations to obtain information about all shared memory segments
on the system.)
A successful
<B>SHM_STAT</B>
operation returns the identifier of the shared memory segment
whose index was given in
<I>shmid</I>.
Other operations return 0 on success.
<P>
On error, -1 is returned, and
<I>errno</I>
is set appropriately.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
<DL COMPACT>
<DT id="16"><B>EACCES</B>
<DD>
<B>IPC_STAT</B> or <B>SHM_STAT</B> is requested and
<I>shm_perm.mode</I> does not allow read access for
<I>shmid</I>,
and the calling process does not have the
<B>CAP_IPC_OWNER</B>
capability in the user namespace that governs its IPC namespace.
<DT id="17"><B>EFAULT</B>
<DD>
The argument
<I>cmd</I>
has value
<B>IPC_SET</B>
or
<B>IPC_STAT</B>
but the address pointed to by
<I>buf</I>
isn't accessible.
<DT id="18"><B>EIDRM</B>
<DD>
<I>shmid</I> points to a removed identifier.
<DT id="19"><B>EINVAL</B>
<DD>
<I>shmid</I> is not a valid identifier, or <I>cmd</I>
is not a valid command.
Or: for a
<B>SHM_STAT</B>
or
<B>SHM_STAT_ANY</B>
operation, the index value specified in
<I>shmid</I>
referred to an array slot that is currently unused.
<DT id="20"><B>ENOMEM</B>
<DD>
(In kernels since 2.6.9),
<B>SHM_LOCK</B>
was specified and the size of the to-be-locked segment would mean
that the total bytes in locked shared memory segments would exceed
the limit for the real user ID of the calling process.
This limit is defined by the
<B>RLIMIT_MEMLOCK</B>
soft resource limit (see
<B><A HREF="/cgi-bin/man/man2html?2+setrlimit">setrlimit</A></B>(2)).
<DT id="21"><B>EOVERFLOW</B>
<DD>
<B>IPC_STAT</B> is attempted, and the GID or UID value
is too large to be stored in the structure pointed to by
<I>buf</I>.
<DT id="22"><B>EPERM</B>
<DD>
<B>IPC_SET</B> or <B>IPC_RMID</B> is attempted, and the
effective user ID of the calling process is not that of the creator
(found in
<I>shm_perm.cuid</I>),
or the owner
(found in
<I>shm_perm.uid</I>),
and the process was not privileged (Linux: did not have the
<B>CAP_SYS_ADMIN</B>
capability).
<DT id="23"><DD>
Or (in kernels before 2.6.9),
<B>SHM_LOCK</B>
or
<B>SHM_UNLOCK</B>
was specified, but the process was not privileged
(Linux: did not have the
<B>CAP_IPC_LOCK</B>
capability).
(Since Linux 2.6.9, this error can also occur if the
<B>RLIMIT_MEMLOCK</B>
is 0 and the caller is not privileged.)
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>CONFORMING TO</H2>
POSIX.1-2001, POSIX.1-2008, SVr4.
<A NAME="lbAH">&nbsp;</A>
<H2>NOTES</H2>
The inclusion of
<I>&lt;<A HREF="file:///usr/include/sys/types.h">sys/types.h</A>&gt;</I>
and
<I>&lt;<A HREF="file:///usr/include/sys/ipc.h">sys/ipc.h</A>&gt;</I>
isn't required on Linux or by any version of POSIX.
However,
some old implementations required the inclusion of these header files,
and the SVID also documented their inclusion.
Applications intended to be portable to such old systems may need
to include these header files.
<P>
The
<B>IPC_INFO</B>,
<B>SHM_STAT</B>
and
<B>SHM_INFO</B>
operations are used by the
<B><A HREF="/cgi-bin/man/man2html?1+ipcs">ipcs</A></B>(1)
program to provide information on allocated resources.
In the future, these may modified or moved to a
<I>/proc</I>
filesystem interface.
<P>
Linux permits a process to attach
(<B><A HREF="/cgi-bin/man/man2html?2+shmat">shmat</A></B>(2))
a shared memory segment that has already been marked for deletion
using
<I>shmctl(IPC_RMID)</I>.
This feature is not available on other UNIX implementations;
portable applications should avoid relying on it.
<P>
Various fields in a <I>struct shmid_ds</I> were typed as
<I>short</I>
under Linux 2.2
and have become
<I>long</I>
under Linux 2.4.
To take advantage of this,
a recompilation under glibc-2.1.91 or later should suffice.
(The kernel distinguishes old and new calls by an
<B>IPC_64</B>
flag in
<I>cmd</I>.)
<A NAME="lbAI">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+mlock">mlock</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+setrlimit">setrlimit</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+shmget">shmget</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+shmop">shmop</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?7+capabilities">capabilities</A></B>(7),
<B><A HREF="/cgi-bin/man/man2html?7+sysvipc">sysvipc</A></B>(7)
<A NAME="lbAJ">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="24"><A HREF="#lbAB">NAME</A><DD>
<DT id="25"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="26"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="27"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="28"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="29"><A HREF="#lbAG">CONFORMING TO</A><DD>
<DT id="30"><A HREF="#lbAH">NOTES</A><DD>
<DT id="31"><A HREF="#lbAI">SEE ALSO</A><DD>
<DT id="32"><A HREF="#lbAJ">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:34 GMT, March 31, 2021
</BODY>
</HTML>