2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
|
2006-05-22 23:52:24 +00:00
|
|
|
.\" and Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" and Copyright 2004, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2004-11-10 17:27:34 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2004-11-10 17:27:34 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" Modified 1993-07-28, Rik Faith <faith@cs.unc.edu>
|
|
|
|
.\" Modified 1993-11-28, Giorgio Ciucci <giorgio@crcc.it>
|
|
|
|
.\" Modified 1997-01-31, Eric S. Raymond <esr@thyrsus.com>
|
|
|
|
.\" Modified 2001-02-18, Andries Brouwer <aeb@cwi.nl>
|
|
|
|
.\" Modified 2002-01-05, 2004-05-27, 2004-06-17,
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Modified 2004-10-11, aeb
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" Modified, Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-10 17:27:34 +00:00
|
|
|
.\" Language and formatting clean-ups
|
|
|
|
.\" Updated shmid_ds structure definitions
|
|
|
|
.\" Added information on SHM_DEST and SHM_LOCKED flags
|
2007-04-12 22:42:49 +00:00
|
|
|
.\" Noted that CAP_IPC_LOCK is not required for SHM_UNLOCK
|
2004-11-23 10:06:02 +00:00
|
|
|
.\" since kernel 2.6.9
|
2004-11-25 13:38:17 +00:00
|
|
|
.\" Modified, 2004-11-25, mtk, notes on 2.6.9 RLIMIT_MEMLOCK changes
|
2007-06-08 09:56:56 +00:00
|
|
|
.\" 2005-04-25, mtk -- noted aberrant Linux behavior w.r.t. new
|
2005-04-25 08:36:43 +00:00
|
|
|
.\" attaches to a segment that has already been marked for deletion.
|
2005-08-02 12:09:50 +00:00
|
|
|
.\" 2005-08-02, mtk: Added IPC_INFO, SHM_INFO, SHM_STAT descriptions.
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
2008-08-06 20:19:17 +00:00
|
|
|
.TH SHMCTL 2 2008-08-07 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
shmctl \- shared memory control
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.ad l
|
|
|
|
.B #include <sys/ipc.h>
|
2007-10-03 06:22:00 +00:00
|
|
|
.br
|
2004-11-03 13:51:07 +00:00
|
|
|
.B #include <sys/shm.h>
|
|
|
|
.sp
|
|
|
|
.BI "int shmctl(int " shmid ", int " cmd ", struct shmid_ds *" buf );
|
|
|
|
.ad b
|
|
|
|
.SH DESCRIPTION
|
2004-12-13 08:39:28 +00:00
|
|
|
.BR shmctl ()
|
2006-05-26 22:01:20 +00:00
|
|
|
performs the control operation specified by
|
|
|
|
.I cmd
|
|
|
|
on the shared memory segment whose identifier is given in
|
|
|
|
.IR shmid .
|
2004-11-10 17:27:34 +00:00
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.I buf
|
|
|
|
argument is a pointer to a \fIshmid_ds\fP structure,
|
2007-06-20 21:53:34 +00:00
|
|
|
defined in \fI<sys/shm.h>\fP as follows:
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
struct shmid_ds {
|
2004-11-10 17:27:34 +00:00
|
|
|
struct ipc_perm shm_perm; /* Ownership and permissions */
|
|
|
|
size_t shm_segsz; /* Size of segment (bytes) */
|
|
|
|
time_t shm_atime; /* Last attach time */
|
|
|
|
time_t shm_dtime; /* Last detach time */
|
|
|
|
time_t shm_ctime; /* Last change time */
|
|
|
|
pid_t shm_cpid; /* PID of creator */
|
2007-05-11 23:07:02 +00:00
|
|
|
pid_t shm_lpid; /* PID of last shmat(2)/shmdt(2) */
|
2004-11-10 17:27:34 +00:00
|
|
|
shmatt_t shm_nattch; /* No. of current attaches */
|
2004-11-03 13:51:07 +00:00
|
|
|
...
|
|
|
|
};
|
|
|
|
.fi
|
2007-12-19 06:57:44 +00:00
|
|
|
.in
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2004-11-10 17:27:34 +00:00
|
|
|
The
|
|
|
|
.I ipc_perm
|
2007-06-20 21:53:34 +00:00
|
|
|
structure is defined in \fI<sys/ipc.h>\fP as follows
|
2004-11-10 17:27:34 +00:00
|
|
|
(the highlighted fields are settable using
|
|
|
|
.BR IPC_SET ):
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
|
|
|
.in +4n
|
|
|
|
.nf
|
|
|
|
struct ipc_perm {
|
2008-08-06 20:18:38 +00:00
|
|
|
key_t __key; /* Key supplied to shmget(2) */
|
2008-08-06 20:17:27 +00:00
|
|
|
uid_t \fBuid\fP; /* Effective UID of owner */
|
|
|
|
gid_t \fBgid\fP; /* Effective GID of owner */
|
|
|
|
uid_t cuid; /* Effective UID of creator */
|
|
|
|
gid_t cgid; /* Effective GID of creator */
|
|
|
|
unsigned short \fBmode\fP; /* \fBPermissions\fP + SHM_DEST and
|
|
|
|
SHM_LOCKED flags */
|
2008-08-06 20:18:38 +00:00
|
|
|
unsigned short __seq; /* Sequence number */
|
2004-11-03 13:51:07 +00:00
|
|
|
};
|
|
|
|
.fi
|
2007-12-19 06:57:44 +00:00
|
|
|
.in
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2004-11-10 17:27:34 +00:00
|
|
|
Valid values for
|
|
|
|
.I cmd
|
|
|
|
are:
|
2004-11-03 13:51:07 +00:00
|
|
|
.br
|
2008-08-06 20:45:26 +00:00
|
|
|
.TP 10
|
2004-11-03 13:51:07 +00:00
|
|
|
.B IPC_STAT
|
2004-11-10 17:27:34 +00:00
|
|
|
Copy information from the kernel data structure associated with
|
|
|
|
.I shmid
|
|
|
|
into the
|
|
|
|
.I shmid_ds
|
|
|
|
structure pointed to by \fIbuf\fP.
|
|
|
|
The caller must have read permission on the
|
2004-11-03 13:51:07 +00:00
|
|
|
shared memory segment.
|
|
|
|
.TP
|
|
|
|
.B IPC_SET
|
2004-11-10 17:27:34 +00:00
|
|
|
Write the values of some members of the
|
|
|
|
.I shmid_ds
|
|
|
|
structure pointed to by
|
2006-12-27 02:50:13 +00:00
|
|
|
.I buf
|
2004-11-10 17:27:34 +00:00
|
|
|
to the kernel data structure associated with this shared memory segment,
|
|
|
|
updating also its
|
2004-11-03 13:51:07 +00:00
|
|
|
.I shm_ctime
|
2004-11-10 17:27:34 +00:00
|
|
|
member.
|
|
|
|
The following fields can be changed:
|
2005-04-25 08:36:43 +00:00
|
|
|
\fIshm_perm.uid\fP, \fIshm_perm.gid\fP,
|
|
|
|
and (the least significant 9 bits of) \fIshm_perm.mode\fP.
|
2004-11-10 17:27:34 +00:00
|
|
|
The effective UID of the calling process must match the owner
|
|
|
|
.RI ( shm_perm.uid )
|
|
|
|
or creator
|
|
|
|
.RI ( shm_perm.cuid )
|
|
|
|
of the shared memory segment, or the caller must be privileged.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B IPC_RMID
|
2004-11-10 17:27:34 +00:00
|
|
|
Mark the segment to be destroyed.
|
|
|
|
The segment will only actually be destroyed
|
|
|
|
after the last process detaches it (i.e., when the
|
2004-11-03 13:51:07 +00:00
|
|
|
.I shm_nattch
|
|
|
|
member of the associated structure
|
|
|
|
.I shmid_ds
|
2004-11-10 17:27:34 +00:00
|
|
|
is zero).
|
|
|
|
The caller must be the owner or creator, or be privileged.
|
accept.2, execve.2, futimesat.2, getresuid.2, getrlimit.2, madvise.2, mq_getsetattr.2, msgctl.2, nice.2, open.2, poll.2, setresuid.2, shmctl.2, sigaction.2, times.2, utimensat.2, __setfpucw.3, atoi.3, endian.3, err.3, euidaccess.3, fenv.3, fopencookie.3, fpurge.3, getgrouplist.3, getutmp.3, j0.3, lgamma.3, netlink.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_cleanup_push_defer_np.3, pthread_getattr_np.3, pthread_kill_other_threads_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, pthread_yield.3, random_r.3, readdir.3, rtnetlink.3, scanf.3, setenv.3, significand.3, sigsetops.3, strerror.3, strstr.3, sysv_signal.3, termios.3, timegm.3, unlocked_stdio.3, y0.3, locale.5, bootparam.7, feature_test_macros.7, ip.7, locale.7, pthreads.7, rtld-audit.7, nscd.8: Global fix: s/non-standard/nonstandard/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:37:52 +00:00
|
|
|
If a segment has been marked for destruction, then the (nonstandard)
|
2004-11-10 17:27:34 +00:00
|
|
|
.B SHM_DEST
|
|
|
|
flag of the
|
|
|
|
.I shm_perm.mode
|
|
|
|
field in the associated data structure retrieved by
|
|
|
|
.B IPC_STAT
|
|
|
|
will be set.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2004-11-10 17:27:34 +00:00
|
|
|
The caller \fImust\fP ensure that a segment is eventually destroyed;
|
|
|
|
otherwise its pages that were faulted in will remain in memory or swap.
|
2008-08-06 20:45:26 +00:00
|
|
|
.TP 10
|
2007-12-25 21:28:09 +00:00
|
|
|
.BR IPC_INFO " (Linux-specific)"
|
2007-04-12 22:42:49 +00:00
|
|
|
Returns information about system-wide shared memory limits and
|
2005-08-02 12:09:50 +00:00
|
|
|
parameters in the structure pointed to by
|
|
|
|
.IR buf .
|
|
|
|
This structure is of type
|
2007-09-20 16:26:31 +00:00
|
|
|
.I shminfo
|
2005-08-02 12:09:50 +00:00
|
|
|
(thus, a cast is required),
|
|
|
|
defined in
|
|
|
|
.I <sys/shm.h>
|
2007-06-22 17:42:06 +00:00
|
|
|
if the
|
|
|
|
.B _GNU_SOURCE
|
|
|
|
feature test macro is defined:
|
2005-08-02 12:09:50 +00:00
|
|
|
.nf
|
2007-12-19 06:57:44 +00:00
|
|
|
.in +4n
|
2005-08-02 12:09:50 +00:00
|
|
|
|
|
|
|
struct shminfo {
|
2008-05-20 21:20:38 +00:00
|
|
|
unsigned long shmmax; /* Maximum segment size */
|
2008-08-06 20:45:26 +00:00
|
|
|
unsigned long shmmin; /* Minimum segment size;
|
|
|
|
always 1 */
|
2008-05-20 21:20:38 +00:00
|
|
|
unsigned long shmmni; /* Maximum number of segments */
|
2008-08-06 20:45:26 +00:00
|
|
|
unsigned long shmseg; /* Maximum number of segments
|
|
|
|
that a process can attach;
|
|
|
|
unused within kernel */
|
2008-05-20 21:20:38 +00:00
|
|
|
unsigned long shmall; /* Maximum number of pages of
|
|
|
|
shared memory, system-wide */
|
2005-08-02 12:09:50 +00:00
|
|
|
};
|
|
|
|
|
2007-12-19 06:57:44 +00:00
|
|
|
.in
|
2005-08-02 12:09:50 +00:00
|
|
|
.fi
|
2007-04-12 22:42:49 +00:00
|
|
|
The
|
2005-08-02 12:09:50 +00:00
|
|
|
.IR shmmni ,
|
|
|
|
.IR shmmax ,
|
2005-05-30 11:58:06 +00:00
|
|
|
and
|
2005-08-02 12:09:50 +00:00
|
|
|
.I shmall
|
|
|
|
settings can be changed via
|
2007-04-12 22:42:49 +00:00
|
|
|
.I /proc
|
2005-08-02 12:09:50 +00:00
|
|
|
files of the same name; see
|
2007-04-12 22:42:49 +00:00
|
|
|
.BR proc (5)
|
2005-08-02 12:09:50 +00:00
|
|
|
for details.
|
|
|
|
.TP
|
2007-12-25 21:28:09 +00:00
|
|
|
.BR SHM_INFO " (Linux-specific)"
|
2005-08-02 12:09:50 +00:00
|
|
|
Returns a
|
|
|
|
.I shm_info
|
2007-04-12 22:42:49 +00:00
|
|
|
structure whose fields contain information
|
2005-08-02 12:09:50 +00:00
|
|
|
about system resources consumed by shared memory.
|
|
|
|
This structure is defined in
|
|
|
|
.I <sys/shm.h>
|
2007-06-22 17:42:06 +00:00
|
|
|
if the
|
|
|
|
.B _GNU_SOURCE
|
|
|
|
feature test macro is defined:
|
2005-08-02 12:09:50 +00:00
|
|
|
.nf
|
2007-12-19 06:57:44 +00:00
|
|
|
.in +4n
|
2005-08-02 12:09:50 +00:00
|
|
|
|
|
|
|
struct shm_info {
|
2008-08-06 20:46:09 +00:00
|
|
|
int used_ids; /* # of currently existing
|
|
|
|
segments */
|
|
|
|
unsigned long shm_tot; /* Total number of shared
|
|
|
|
memory pages */
|
|
|
|
unsigned long shm_rss; /* # of resident shared
|
|
|
|
memory pages */
|
|
|
|
unsigned long shm_swp; /* # of swapped shared
|
|
|
|
memory pages */
|
2008-08-06 20:41:47 +00:00
|
|
|
unsigned long swap_attempts;
|
2008-08-06 20:46:09 +00:00
|
|
|
/* Unused since Linux 2.4 */
|
2008-08-06 20:41:47 +00:00
|
|
|
unsigned long swap_successes;
|
2008-08-06 20:46:09 +00:00
|
|
|
/* Unused since Linux 2.4 */
|
2005-08-02 12:09:50 +00:00
|
|
|
};
|
2007-12-19 06:57:44 +00:00
|
|
|
.in
|
2005-08-02 12:09:50 +00:00
|
|
|
.fi
|
|
|
|
.TP
|
2007-12-25 21:28:09 +00:00
|
|
|
.BR SHM_STAT " (Linux-specific)"
|
2007-04-12 22:42:49 +00:00
|
|
|
Returns a
|
|
|
|
.I shmid_ds
|
2005-08-02 12:09:50 +00:00
|
|
|
structure as for
|
|
|
|
.BR IPC_STAT .
|
|
|
|
However, the
|
|
|
|
.I shmid
|
|
|
|
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.
|
2005-05-30 11:58:06 +00:00
|
|
|
.PP
|
|
|
|
The caller can prevent or allow swapping of a shared
|
2004-11-10 17:27:34 +00:00
|
|
|
memory segment with the following \fIcmd\fP values:
|
2004-11-03 13:51:07 +00:00
|
|
|
.br
|
2008-08-06 20:45:26 +00:00
|
|
|
.TP 10
|
2007-12-25 21:28:09 +00:00
|
|
|
.BR SHM_LOCK " (Linux-specific)"
|
2007-04-12 22:42:49 +00:00
|
|
|
Prevent swapping of the shared memory segment.
|
|
|
|
The caller must fault in
|
2004-11-03 13:51:07 +00:00
|
|
|
any pages that are required to be present after locking is enabled.
|
accept.2, execve.2, futimesat.2, getresuid.2, getrlimit.2, madvise.2, mq_getsetattr.2, msgctl.2, nice.2, open.2, poll.2, setresuid.2, shmctl.2, sigaction.2, times.2, utimensat.2, __setfpucw.3, atoi.3, endian.3, err.3, euidaccess.3, fenv.3, fopencookie.3, fpurge.3, getgrouplist.3, getutmp.3, j0.3, lgamma.3, netlink.3, pthread_attr_init.3, pthread_attr_setaffinity_np.3, pthread_cleanup_push_defer_np.3, pthread_getattr_np.3, pthread_kill_other_threads_np.3, pthread_setaffinity_np.3, pthread_tryjoin_np.3, pthread_yield.3, random_r.3, readdir.3, rtnetlink.3, scanf.3, setenv.3, significand.3, sigsetops.3, strerror.3, strstr.3, sysv_signal.3, termios.3, timegm.3, unlocked_stdio.3, y0.3, locale.5, bootparam.7, feature_test_macros.7, ip.7, locale.7, pthreads.7, rtld-audit.7, nscd.8: Global fix: s/non-standard/nonstandard/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 16:37:52 +00:00
|
|
|
If a segment has been locked, then the (nonstandard)
|
2007-09-20 16:26:31 +00:00
|
|
|
.B SHM_LOCKED
|
2004-11-10 17:27:34 +00:00
|
|
|
flag of the
|
|
|
|
.I shm_perm.mode
|
|
|
|
field in the associated data structure retrieved by
|
|
|
|
.B IPC_STAT
|
|
|
|
will be set.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2007-12-25 21:28:09 +00:00
|
|
|
.BR SHM_UNLOCK " (Linux-specific)"
|
2004-11-10 17:27:34 +00:00
|
|
|
Unlock the segment, allowing it to be swapped out.
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2005-05-30 11:58:06 +00:00
|
|
|
In kernels before 2.6.10, only a privileged process
|
|
|
|
could employ
|
|
|
|
.B SHM_LOCK
|
2004-11-03 13:51:07 +00:00
|
|
|
and
|
2005-05-30 11:58:06 +00:00
|
|
|
.BR SHM_UNLOCK .
|
2007-04-12 22:42:49 +00:00
|
|
|
Since kernel 2.6.10, an unprivileged process can employ these operations
|
2005-05-30 11:58:06 +00:00
|
|
|
if its effective UID matches the owner or creator UID of the segment, and
|
|
|
|
(for
|
|
|
|
.BR SHM_LOCK )
|
|
|
|
the amount of memory to be locked falls within the
|
2007-09-20 16:26:31 +00:00
|
|
|
.B RLIMIT_MEMLOCK
|
2005-05-30 11:58:06 +00:00
|
|
|
resource limit (see
|
|
|
|
.BR setrlimit (2)).
|
2007-04-12 22:42:49 +00:00
|
|
|
.\" There was some weirdness in 2.6.9: SHM_LOCK and SHM_UNLOCK could
|
2005-05-30 11:58:06 +00:00
|
|
|
.\" be applied to a segment, regardless of ownership of the segment.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\" This was a botch-up in the move to RLIMIT_MEMLOCK, and was fixed
|
2005-05-30 11:58:06 +00:00
|
|
|
.\" in 2.6.10. MTK, May 2005
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "RETURN VALUE"
|
2005-08-02 12:09:50 +00:00
|
|
|
A successful
|
|
|
|
.B IPC_INFO
|
2007-04-12 22:42:49 +00:00
|
|
|
or
|
2005-08-02 12:09:50 +00:00
|
|
|
.B SHM_INFO
|
|
|
|
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
|
2007-04-12 22:42:49 +00:00
|
|
|
.B SHM_STAT
|
|
|
|
operations to obtain information about all shared memory segments
|
2005-08-02 12:09:50 +00:00
|
|
|
on the system.)
|
|
|
|
A successful
|
|
|
|
.B SHM_STAT
|
2007-04-12 22:42:49 +00:00
|
|
|
operation returns the identifier of the shared memory segment
|
2005-08-02 12:09:50 +00:00
|
|
|
whose index was given in
|
|
|
|
.IR shmid .
|
|
|
|
Other operations return 0 on success.
|
|
|
|
|
2004-11-03 13:51:07 +00:00
|
|
|
On error, \-1 is returned, and
|
|
|
|
.I errno
|
|
|
|
is set appropriately.
|
|
|
|
.SH ERRORS
|
2008-08-06 20:33:17 +00:00
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B EACCES
|
|
|
|
\fBIPC_STAT\fP or \fBSHM_STAT\fP is requested and
|
2005-04-25 08:36:43 +00:00
|
|
|
\fIshm_perm.mode\fP does not allow read access for
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR shmid ,
|
|
|
|
and the calling process does not have the
|
2007-09-20 16:26:31 +00:00
|
|
|
.B CAP_IPC_OWNER
|
2004-11-03 13:51:07 +00:00
|
|
|
capability.
|
|
|
|
.TP
|
|
|
|
.B EFAULT
|
|
|
|
The argument
|
|
|
|
.I cmd
|
|
|
|
has value
|
|
|
|
.B IPC_SET
|
|
|
|
or
|
|
|
|
.B IPC_STAT
|
|
|
|
but the address pointed to by
|
|
|
|
.I buf
|
|
|
|
isn't accessible.
|
|
|
|
.TP
|
|
|
|
.B EIDRM
|
|
|
|
\fIshmid\fP points to a removed identifier.
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
|
|
|
\fIshmid\fP is not a valid identifier, or \fIcmd\fP
|
|
|
|
is not a valid command.
|
2005-08-02 12:09:50 +00:00
|
|
|
Or: for a
|
|
|
|
.B SHM_STAT
|
2007-04-12 22:42:49 +00:00
|
|
|
operation, the index value specified in
|
2005-08-02 12:09:50 +00:00
|
|
|
.I shmid
|
|
|
|
referred to an array slot that is currently unused.
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
2004-11-25 13:38:17 +00:00
|
|
|
.B ENOMEM
|
|
|
|
(In kernels since 2.6.9),
|
|
|
|
.B SHM_LOCK
|
2007-04-12 22:42:49 +00:00
|
|
|
was specified and the size of the to-be-locked segment would mean
|
2004-11-25 13:38:17 +00:00
|
|
|
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
|
2007-09-20 16:26:31 +00:00
|
|
|
.B RLIMIT_MEMLOCK
|
2004-11-25 13:38:17 +00:00
|
|
|
soft resource limit (see
|
|
|
|
.BR setrlimit (2)).
|
|
|
|
.TP
|
2004-11-03 13:51:07 +00:00
|
|
|
.B EOVERFLOW
|
2005-07-18 15:54:49 +00:00
|
|
|
\fBIPC_STAT\fP is attempted, and the GID or UID value
|
2004-11-03 13:51:07 +00:00
|
|
|
is too large to be stored in the structure pointed to by
|
2004-11-10 17:27:34 +00:00
|
|
|
.IR buf .
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B EPERM
|
|
|
|
\fBIPC_SET\fP or \fBIPC_RMID\fP is attempted, and the
|
|
|
|
effective user ID of the calling process is not that of the creator
|
|
|
|
(found in
|
|
|
|
.IR shm_perm.cuid ),
|
|
|
|
or the owner
|
|
|
|
(found in
|
|
|
|
.IR shm_perm.uid ),
|
|
|
|
and the process was not privileged (Linux: did not have the
|
|
|
|
.B CAP_SYS_ADMIN
|
|
|
|
capability).
|
|
|
|
|
2004-11-25 13:38:17 +00:00
|
|
|
Or (in kernels before 2.6.9),
|
2004-11-03 13:51:07 +00:00
|
|
|
.B SHM_LOCK
|
|
|
|
or
|
|
|
|
.B SHM_UNLOCK
|
|
|
|
was specified, but the process was not privileged
|
|
|
|
(Linux: did not have the
|
|
|
|
.B CAP_IPC_LOCK
|
|
|
|
capability).
|
2004-11-25 13:38:17 +00:00
|
|
|
(Since Linux 2.6.9, this error can also occur if the
|
2007-09-20 16:26:31 +00:00
|
|
|
.B RLIMIT_MEMLOCK
|
2004-11-25 13:38:17 +00:00
|
|
|
is 0 and the caller is not privileged.)
|
2007-05-18 16:06:42 +00:00
|
|
|
.SH "CONFORMING TO"
|
|
|
|
SVr4, POSIX.1-2001.
|
|
|
|
.\" SVr4 documents additional error conditions EINVAL,
|
|
|
|
.\" ENOENT, ENOSPC, ENOMEM, EEXIST. Neither SVr4 nor SVID documents
|
|
|
|
.\" an EIDRM error condition.
|
2005-04-25 08:36:43 +00:00
|
|
|
.SH NOTES
|
2005-08-02 12:09:50 +00:00
|
|
|
The
|
|
|
|
.BR IPC_INFO ,
|
2007-09-20 16:26:31 +00:00
|
|
|
.B SHM_STAT
|
2005-08-02 12:09:50 +00:00
|
|
|
and
|
|
|
|
.B SHM_INFO
|
|
|
|
operations are used by the
|
2010-06-13 09:12:43 +00:00
|
|
|
.BR ipcs (1)
|
2005-08-02 12:09:50 +00:00
|
|
|
program to provide information on allocated resources.
|
|
|
|
In the future these may modified or moved to a /proc file system
|
|
|
|
interface.
|
|
|
|
|
2007-04-12 22:42:49 +00:00
|
|
|
Linux permits a process to attach
|
2007-05-11 23:07:02 +00:00
|
|
|
.RB ( shmat (2))
|
2005-04-25 08:36:43 +00:00
|
|
|
a shared memory segment that has already been marked for deletion
|
|
|
|
using
|
|
|
|
.IR shmctl(IPC_RMID) .
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
This feature is not available on other UNIX implementations;
|
2005-04-25 08:36:43 +00:00
|
|
|
portable applications should avoid relying on it.
|
|
|
|
|
2007-06-25 10:03:10 +00:00
|
|
|
Various fields in a \fIstruct shmid_ds\fP were typed as
|
|
|
|
.I short
|
|
|
|
under Linux 2.2
|
|
|
|
and have become
|
|
|
|
.I long
|
|
|
|
under Linux 2.4.
|
2007-04-12 22:42:49 +00:00
|
|
|
To take advantage of this,
|
2004-11-03 13:51:07 +00:00
|
|
|
a recompilation under glibc-2.1.91 or later should suffice.
|
2007-06-22 20:40:07 +00:00
|
|
|
(The kernel distinguishes old and new calls by an
|
|
|
|
.B IPC_64
|
|
|
|
flag in
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR cmd .)
|
|
|
|
.SH "SEE ALSO"
|
2004-11-10 17:27:34 +00:00
|
|
|
.BR mlock (2),
|
2004-11-25 13:38:17 +00:00
|
|
|
.BR setrlimit (2),
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR shmget (2),
|
|
|
|
.BR shmop (2),
|
2007-06-28 20:44:32 +00:00
|
|
|
.BR capabilities (7),
|
|
|
|
.BR svipc (7)
|