]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man2/shmop.2
pldd.1, bpf.2, chdir.2, clone.2, fanotify_init.2, fanotify_mark.2, intro.2, ipc.2...
[thirdparty/man-pages.git] / man2 / shmop.2
index 79c1dfc112d7b923178159dd37de96cf5a823c56..67c3fee6f6d6d49b933839efc9dad5e47ac77453 100644 (file)
 .\"
 .\" FIXME . Add an example program to this page.
 .\"
-.TH SHMOP 2 2014-04-28 "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
@@ -63,7 +63,7 @@ with one of the following criteria:
 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
@@ -93,7 +93,7 @@ Allow the contents of the segment to be executed.
 The caller must have execute permission on the segment.
 .TP
 .BR SHM_RDONLY
-Attach the segment read-only access.
+Attach the segment for read-only access.
 The process must have read permission for the segment.
 If this flag is not specified,
 the segment is attached for read and write access,
@@ -173,7 +173,7 @@ returns the address of the attached shared memory segment; on error,
 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
@@ -190,7 +190,7 @@ is set to one of the following:
 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.
@@ -226,9 +226,9 @@ or,
 .I shmaddr
 is not aligned on a page boundary.
 .SH CONFORMING TO
-SVr4, POSIX.1-2001.
+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\ *"
@@ -240,24 +240,20 @@ from
 .I "char\ *"
 into
 .IR "void\ *" .
-(Linux libc4 and libc5 have the
-.I "char\ *"
-prototypes; glibc2 has
-.IR "void\ *" .)
 .SH NOTES
 .PP
 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
@@ -272,24 +268,26 @@ rather than absolute.
 .PP
 On Linux, it is possible to attach a shared memory segment even if it
 is already marked to be deleted.
-However, POSIX.1-2001 does not specify this behavior and
+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
-.\" FIXME A good explanation of the rationale for the existence
-.\" of SHMLBA would be useful here
 .B SHMLBA
 Segment low boundary address multiple.
-Must be page aligned.
-For the current implementation, the
+When explicitly specifying an attach address in a call to
+.BR shmat (),
+the caller should ensure that the address is a multiple of this value.
+This is necessary on some architectures,
+in order either to ensure good CPU cache performance or to ensure that
+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,
 .B SHMLBA
-value is
-.BR PAGE_SIZE .
-.\" FIXME That last sentence isn't true for all Linux
-.\" architectures (i.e., SHMLBA != PAGE_SIZE for some architectures)
-.\" -- MTK, Nov 04
+is the same as the system page size.)
 .PP
 The implementation places no intrinsic per-process limit on the
 number of shared memory segments
@@ -301,4 +299,4 @@ number of shared memory segments
 .BR shmget (2),
 .BR capabilities (7),
 .BR shm_overview (7),
-.BR svipc (7)
+.BR sysvipc (7)