summaryrefslogtreecommitdiffstats
path: root/man2/semget.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/semget.2')
-rw-r--r--man2/semget.230
1 files changed, 15 insertions, 15 deletions
diff --git a/man2/semget.2 b/man2/semget.2
index bd2b693..50813ba 100644
--- a/man2/semget.2
+++ b/man2/semget.2
@@ -14,7 +14,7 @@
.\" Rewrote BUGS note about semget()'s failure to initialize
.\" semaphore values
.\"
-.TH semget 2 2023-05-03 "Linux man-pages 6.05.01"
+.TH semget 2 2023-10-31 "Linux man-pages 6.7"
.SH NAME
semget \- get a System V semaphore set identifier
.SH LIBRARY
@@ -24,7 +24,7 @@ Standard C library
.nf
.B #include <sys/sem.h>
.fi
-.PP
+.P
.BI "int semget(key_t " key ,
.BI "int " nsems ,
.BI "int " semflg );
@@ -42,7 +42,7 @@ is zero and
does not have the value
.BR IPC_PRIVATE ),
or to create a new set.
-.PP
+.P
A new set of
.I nsems
semaphores is created if
@@ -55,7 +55,7 @@ and
.B IPC_CREAT
is specified in
.IR semflg .
-.PP
+.P
If
.I semflg
specifies both
@@ -74,7 +74,7 @@ set to
.B O_CREAT | O_EXCL
for
.BR open (2).)
-.PP
+.P
Upon creation, the least significant 9 bits of the argument
.I semflg
define the permissions (for owner, group, and others)
@@ -87,7 +87,7 @@ argument of
(though the execute permissions are
not meaningful for semaphores, and write permissions mean permission
to alter semaphore values).
-.PP
+.P
When creating a new semaphore set,
.BR semget ()
initializes the set's associated data structure,
@@ -120,7 +120,7 @@ is set to 0.
.IP \[bu]
.I sem_ctime
is set to the current time.
-.PP
+.P
The argument
.I nsems
can be 0
@@ -131,7 +131,7 @@ Otherwise,
must be greater than 0
and less than or equal to the maximum number of semaphores per semaphore set
.RB ( SEMMSL ).
-.PP
+.P
If the semaphore set already exists, the permissions are
verified.
.\" and a check is made to see if it is marked for destruction.
@@ -225,7 +225,7 @@ it should explicitly initialize the semaphores to the desired values.
.\" In truth, every one of the many implementations that I've tested sets
.\" the values to zero, but I suppose there is/was some obscure
.\" implementation out there that does not.
-.PP
+.P
Initialization can be done using
.BR semctl (2)
.B SETVAL
@@ -310,12 +310,12 @@ and
flags for the call to
.BR semget ().
The usage of this program is demonstrated below.
-.PP
+.P
We first create two files that will be used to generate keys using
.BR ftok (3),
create two semaphore sets using those files, and then list the sets using
.BR ipcs (1):
-.PP
+.P
.in +4n
.EX
$ \fBtouch mykey mykey2\fP
@@ -331,7 +331,7 @@ key semid owner perms nsems
0x70041368 10 mtk 600 2
.EE
.in
-.PP
+.P
Next, we demonstrate that when
.BR semctl (2)
is given the same
@@ -339,20 +339,20 @@ is given the same
(as generated by the same arguments to
.BR ftok (3)),
it returns the ID of the already existing semaphore set:
-.PP
+.P
.in +4n
.EX
$ \fB./t_semget \-c mykey p 1\fP
ID = 9
.EE
.in
-.PP
+.P
Finally, we demonstrate the kind of collision that can occur when
.BR ftok (3)
is given different
.I pathname
arguments that have the same inode number:
-.PP
+.P
.in +4n
.EX
$ \fBln mykey link\fP