summaryrefslogtreecommitdiffstats
path: root/man2/shmop.2
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--man2/shmop.248
1 files changed, 24 insertions, 24 deletions
diff --git a/man2/shmop.2 b/man2/shmop.2
index 09168ec..a763420 100644
--- a/man2/shmop.2
+++ b/man2/shmop.2
@@ -17,7 +17,7 @@
.\" Changed wording and placement of sentence regarding attachment
.\" of segments marked for destruction
.\"
-.TH SHMOP 2 2023-05-03 "Linux man-pages 6.05.01"
+.TH SHMOP 2 2023-10-31 "Linux man-pages 6.7"
.SH NAME
shmat, shmdt \- System V shared memory operations
.SH LIBRARY
@@ -26,7 +26,7 @@ Standard C library
.SH SYNOPSIS
.nf
.B #include <sys/shm.h>
-.PP
+.P
.BI "void *shmat(int " shmid ", const void *_Nullable " shmaddr ", \
int " shmflg );
.BI "int shmdt(const void *" shmaddr );
@@ -62,7 +62,7 @@ rounded down to the nearest multiple of
Otherwise,
.I shmaddr
must be a page-aligned address at which the attach occurs.
-.PP
+.P
In addition to
.BR SHM_RND ,
the following flags may be specified in the
@@ -93,14 +93,14 @@ error would result if a mapping already exists in this address range.)
In this case,
.I shmaddr
must not be NULL.
-.PP
+.P
The
.BR brk (2)
value of the calling process is not altered by the attach.
The segment will automatically be detached at process exit.
The same segment may be attached as a read and as a read-write
one, and more than once, in the process's address space.
-.PP
+.P
A successful
.BR shmat ()
call updates the members of the
@@ -129,7 +129,7 @@ attached with
equal to the value returned by the attaching
.BR shmat ()
call.
-.PP
+.P
On a successful
.BR shmdt ()
call, the system updates the members of the
@@ -154,7 +154,7 @@ returns the address of the attached shared memory segment; on error,
is returned, and
.I errno
is set to indicate the error.
-.PP
+.P
On success,
.BR shmdt ()
returns 0; on error \-1 is returned, and
@@ -189,7 +189,7 @@ was NULL.
.TP
.B ENOMEM
Could not allocate memory for the descriptor or for the page tables.
-.PP
+.P
.BR shmdt ()
can fail with one of the following errors:
.TP
@@ -205,7 +205,7 @@ POSIX.1-2008.
.SH HISTORY
POSIX.1-2001, SVr4.
.\" SVr4 documents an additional error condition EMFILE.
-.PP
+.P
In SVID 3 (or perhaps earlier),
the type of the \fIshmaddr\fP argument was changed from
.I "char\ *"
@@ -221,15 +221,15 @@ into
After a
.BR fork (2),
the child inherits the attached shared memory segments.
-.PP
+.P
After an
.BR execve (2),
all attached shared memory segments are detached from the process.
-.PP
+.P
Upon
.BR _exit (2),
all attached shared memory segments are detached from the process.
-.PP
+.P
Using
.BR shmat ()
with
@@ -241,12 +241,12 @@ may be attached at different addresses in different processes.
Therefore, any pointers maintained within the shared memory must be
made relative (typically to the starting address of the segment),
rather than absolute.
-.PP
+.P
On Linux, it is possible to attach a shared memory segment even if it
is already marked to be deleted.
However, POSIX.1 does not specify this behavior and
many other implementations do not support it.
-.PP
+.P
The following system parameter affects
.BR shmat ():
.TP
@@ -264,7 +264,7 @@ is normally some multiple of the system page size.
(On many Linux architectures,
.B SHMLBA
is the same as the system page size.)
-.PP
+.P
The implementation places no intrinsic per-process limit on the
number of shared memory segments
.RB ( SHMSEG ).
@@ -272,37 +272,37 @@ number of shared memory segments
The two programs shown below exchange a string using a shared memory segment.
Further details about the programs are given below.
First, we show a shell session demonstrating their use.
-.PP
+.P
In one terminal window, we run the "reader" program,
which creates a System V shared memory segment and a System V semaphore set.
The program prints out the IDs of the created objects,
and then waits for the semaphore to change value.
-.PP
+.P
.in +4n
.EX
$ \fB./svshm_string_read\fP
shmid = 1114194; semid = 15
.EE
.in
-.PP
+.P
In another terminal window, we run the "writer" program.
The "writer" program takes three command-line arguments:
the IDs of the shared memory segment and semaphore set created
by the "reader", and a string.
It attaches the existing shared memory segment,
copies the string to the shared memory, and modifies the semaphore value.
-.PP
+.P
.in +4n
.EX
$ \fB./svshm_string_write 1114194 15 \[aq]Hello, world\[aq]\fP
.EE
.in
-.PP
+.P
Returning to the terminal where the "reader" is running,
we see that the program has ceased waiting on the semaphore
and has printed the string that was copied into the
shared memory segment by the writer:
-.PP
+.P
.in +4n
.EX
Hello, world
@@ -311,7 +311,7 @@ Hello, world
.\"
.SS Program source: svshm_string.h
The following header file is included by the "reader" and "writer" programs:
-.PP
+.P
.in +4n
.\" SRC BEGIN (svshm_string.h)
.EX
@@ -352,7 +352,7 @@ and initializes the semaphore value to 1.
Finally, the program waits for the semaphore value to become 0,
and afterwards prints the string that has been copied into the
shared memory segment by the "writer".
-.PP
+.P
.in +4n
.\" SRC BEGIN (svshm_string_read.c)
.EX
@@ -434,7 +434,7 @@ that have already been created by the "reader", and a string.
It attaches the shared memory segment into its address space,
and then decrements the semaphore value to 0 in order to inform the
"reader" that it can now examine the contents of the shared memory.
-.PP
+.P
.in +4n
.\" SRC BEGIN (svshm_string_write.c)
.EX