.\"
.\" FIXME . Add an example program to this page.
.\"
-.TH SHMOP 2 2014-07-08 "Linux" "Linux Programmer's Manual"
+.TH SHMOP 2 2019-08-02 "Linux" "Linux Programmer's Manual"
.SH NAME
shmat, shmdt \- System V shared memory operations
.SH SYNOPSIS
.nf
.B #include <sys/types.h>
.B #include <sys/shm.h>
-
+.PP
.BI "void *shmat(int " shmid ", const void *" shmaddr ", int " shmflg );
-
+.PP
.BI "int shmdt(const void *" shmaddr );
.fi
.SH DESCRIPTION
If
.I shmaddr
is NULL,
-the system chooses a suitable (unused) address at which to attach
+the system chooses a suitable (unused) page-aligned address to attach
the segment.
.IP *
If
is returned, and
.I errno
is set to indicate the cause of the error.
-
+.PP
On success,
.BR shmdt ()
returns 0; on error \-1 is returned, and
The calling process does not have the required permissions for
the requested attach type, and does not have the
.B CAP_IPC_OWNER
-capability.
+capability in the user namespace that governs its IPC namespace.
.TP
.B EIDRM
\fIshmid\fP points to a removed identifier.
.SH CONFORMING TO
POSIX.1-2001, POSIX.1-2008, SVr4.
.\" SVr4 documents an additional error condition EMFILE.
-
+.PP
In SVID 3 (or perhaps earlier),
the type of the \fIshmaddr\fP argument was changed from
.I "char\ *"
After a
.BR fork (2),
the child inherits the attached shared memory segments.
-
+.PP
After an
.BR execve (2),
all attached shared memory segments are detached from the process.
-
+.PP
Upon
.BR _exit (2),
all attached shared memory segments are detached from the process.
-
+.PP
Using
.BR shmat ()
with
is already marked to be deleted.
However, POSIX.1 does not specify this behavior and
many other implementations do not support it.
-.LP
+.PP
The following system parameter affects
.BR shmat ():
.TP
different attaches of the same segment have consistent views
within the CPU cache.
.B SHMLBA
-is normally some multiple of the system page size
-(on many Linux architectures, it is the same as the system page size).
+is normally some multiple of the system page size.
+(On many Linux architectures,
+.B SHMLBA
+is the same as the system page size.)
.PP
The implementation places no intrinsic per-process limit on the
number of shared memory segments
.BR shmget (2),
.BR capabilities (7),
.BR shm_overview (7),
-.BR svipc (7)
+.BR sysvipc (7)