]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man2/msgget.2
pldd.1, bpf.2, chdir.2, clone.2, fanotify_init.2, fanotify_mark.2, intro.2, ipc.2...
[thirdparty/man-pages.git] / man2 / msgget.2
index cc7f35525594c74143f5c434638acf85d3cb7a89..b7b95b66e4d575d37b4e66eb9d05e0dc3f77e50b 100644 (file)
@@ -1,7 +1,8 @@
 .\" Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
 .\"
 .\" Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
 .\"
+.\" %%%LICENSE_START(VERBATIM)
 .\" Permission is granted to make and distribute verbatim copies of this
 .\" Permission is granted to make and distribute verbatim copies of this
-.\" manual provflags the copyright notice and this permission notice are
+.\" 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
 .\" preserved on all copies.
 .\"
 .\" Permission is granted to copy and distribute modified versions of this
@@ -19,6 +20,7 @@
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
 .\"
 .\" Formatted or processed versions of this manual, if unaccompanied by
 .\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
 .\"
 .\" Added correction due to Nick Duffek <nsd@bbc.com>, aeb, 960426
 .\" Modified Wed Nov  6 04:00:31 1996 by Eric S. Raymond <esr@thyrsus.com>
 .\"
 .\" Added correction due to Nick Duffek <nsd@bbc.com>, aeb, 960426
 .\" Modified Wed Nov  6 04:00:31 1996 by Eric S. Raymond <esr@thyrsus.com>
 .\"    Language and formatting clean-ups
 .\"    Added notes on /proc files
 .\"
 .\"    Language and formatting clean-ups
 .\"    Added notes on /proc files
 .\"
-.TH MSGGET 2 2004-05-27 "Linux" "Linux Programmer's Manual"
+.TH MSGGET 2 2019-08-02 "Linux" "Linux Programmer's Manual"
 .SH NAME
 .SH NAME
-msgget \- get a message queue identifier
+msgget \- get a System V message queue identifier
 .SH SYNOPSIS
 .nf
 .B #include <sys/types.h>
 .B #include <sys/ipc.h>
 .B #include <sys/msg.h>
 .SH SYNOPSIS
 .nf
 .B #include <sys/types.h>
 .B #include <sys/ipc.h>
 .B #include <sys/msg.h>
-.fi
-.sp
+.PP
 .BI "int msgget(key_t " key ", int " msgflg );
 .BI "int msgget(key_t " key ", int " msgflg );
+.fi
 .SH DESCRIPTION
 The
 .BR msgget ()
 .SH DESCRIPTION
 The
 .BR msgget ()
-system call returns the message queue identifier associated
+system call returns the System\ V message queue identifier associated
 with the value of the
 .I key
 argument.
 with the value of the
 .I key
 argument.
+It may be used either to obtain the identifier of a previously created
+message queue (when
+.I msgflg
+is zero and
+.I key
+does not have the value
+.BR IPC_PRIVATE ),
+or to create a new set.
+.PP
 A new message queue is created if
 .I key
 has the value
 A new message queue is created if
 .I key
 has the value
@@ -117,7 +128,7 @@ are set to the least significant 9 bits of
 .IR msg_qnum ,
 .IR msg_lspid ,
 .IR msg_lrpid ,
 .IR msg_qnum ,
 .IR msg_lspid ,
 .IR msg_lrpid ,
-.I msg_stime
+.IR msg_stime ,
 and
 .I msg_rtime
 are set to 0.
 and
 .I msg_rtime
 are set to 0.
@@ -132,9 +143,9 @@ is set to the system limit
 If the message queue already exists the permissions are
 verified, and a check is made to see if it is marked for
 destruction.
 If the message queue already exists the permissions are
 verified, and a check is made to see if it is marked for
 destruction.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
 If successful, the return value will be the message queue identifier (a
 If successful, the return value will be the message queue identifier (a
-non-negative integer), otherwise \-1
+nonnegative integer), otherwise \-1
 with
 .I errno
 indicating the error.
 with
 .I errno
 indicating the error.
@@ -142,24 +153,23 @@ indicating the error.
 On failure,
 .I errno
 is set to one of the following values:
 On failure,
 .I errno
 is set to one of the following values:
-.TP 11
+.TP
 .B EACCES
 A message queue exists for
 .IR key ,
 but the calling process does not have permission to access the queue,
 and does not have the
 .B CAP_IPC_OWNER
 .B EACCES
 A message queue exists for
 .IR key ,
 but the calling process does not have permission to access the queue,
 and does not have the
 .B CAP_IPC_OWNER
-capability.
+capability in the user namespace that governs its IPC namespace.
 .TP
 .B EEXIST
 .TP
 .B EEXIST
-A message queue exists for
-.I key
-and
-.I msgflg
-specified both
 .B IPC_CREAT
 and
 .B IPC_CREAT
 and
-.BR IPC_EXCL .
+.BR IPC_EXCL
+were specified in
+.IR msgflg ,
+but a message queue already exists for
+.IR key .
 .TP
 .B ENOENT
 No message queue exists for
 .TP
 .B ENOENT
 No message queue exists for
@@ -178,9 +188,22 @@ A message queue has to be created but the system limit for the maximum
 number of message queues
 .RB ( MSGMNI )
 would be exceeded.
 number of message queues
 .RB ( MSGMNI )
 would be exceeded.
-.SH "CONFORMING TO"
-SVr4, POSIX.1-2001.
+.SH CONFORMING TO
+POSIX.1-2001, POSIX.1-2008, SVr4.
 .SH NOTES
 .SH NOTES
+The inclusion of
+.I <sys/types.h>
+and
+.I <sys/ipc.h>
+isn't required on Linux or by any version of POSIX.
+However,
+some old implementations required the inclusion of these header files,
+and the SVID also documented their inclusion.
+Applications intended to be portable to such old systems may need
+to include these header files.
+.\" Like Linux, the FreeBSD man pages still document
+.\" the inclusion of these header files.
+.PP
 .B IPC_PRIVATE
 isn't a flag field but a
 .I key_t
 .B IPC_PRIVATE
 isn't a flag field but a
 .I key_t
@@ -194,14 +217,18 @@ and creates a new message queue (on success).
 The following is a system limit on message queue resources affecting a
 .BR msgget ()
 call:
 The following is a system limit on message queue resources affecting a
 .BR msgget ()
 call:
-.TP 11
+.TP
 .B MSGMNI
 .B MSGMNI
-System wide maximum number of message queues: policy
-dependent
-(on Linux, this limit can be read and modified via
-.IR /proc/sys/kernel/msgmni ).
-.SS "Linux Notes"
-Until version 2.3.20 Linux would return
+System-wide limit on the number of message queues.
+Before Linux 3.19,
+.\" commit 0050ee059f7fc86b1df2527aaa14ed5dc72f9973
+the default value for this limit was calculated using a formula
+based on available system memory.
+Since Linux 3.19, the default value is 32,000.
+On Linux, this limit can be read and modified via
+.IR /proc/sys/kernel/msgmni .
+.SS Linux notes
+Until version 2.3.20, Linux would return
 .B EIDRM
 for a
 .BR msgget ()
 .B EIDRM
 for a
 .BR msgget ()
@@ -212,11 +239,11 @@ The name choice
 was perhaps unfortunate,
 .B IPC_NEW
 would more clearly show its function.
 was perhaps unfortunate,
 .B IPC_NEW
 would more clearly show its function.
-.SH "SEE ALSO"
+.SH SEE ALSO
 .BR msgctl (2),
 .BR msgrcv (2),
 .BR msgsnd (2),
 .BR ftok (3),
 .BR capabilities (7),
 .BR mq_overview (7),
 .BR msgctl (2),
 .BR msgrcv (2),
 .BR msgsnd (2),
 .BR ftok (3),
 .BR capabilities (7),
 .BR mq_overview (7),
-.BR svipc (7)
+.BR sysvipc (7)