xref: /freebsd/lib/libsys/msgget.2 (revision 8269e7673cf033aba67dab8264fe719920c70f87)
1*8269e767SBrooks Davis.\"	$NetBSD: msgget.2,v 1.1 1995/10/16 23:49:19 jtc Exp $
2*8269e767SBrooks Davis.\"
3*8269e767SBrooks Davis.\" Copyright (c) 1995 Frank van der Linden
4*8269e767SBrooks Davis.\" All rights reserved.
5*8269e767SBrooks Davis.\"
6*8269e767SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
7*8269e767SBrooks Davis.\" modification, are permitted provided that the following conditions
8*8269e767SBrooks Davis.\" are met:
9*8269e767SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
10*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
11*8269e767SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
12*8269e767SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
13*8269e767SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
14*8269e767SBrooks Davis.\" 3. All advertising materials mentioning features or use of this software
15*8269e767SBrooks Davis.\"    must display the following acknowledgement:
16*8269e767SBrooks Davis.\"      This product includes software developed for the NetBSD Project
17*8269e767SBrooks Davis.\"      by Frank van der Linden
18*8269e767SBrooks Davis.\" 4. The name of the author may not be used to endorse or promote products
19*8269e767SBrooks Davis.\"    derived from this software without specific prior written permission
20*8269e767SBrooks Davis.\"
21*8269e767SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22*8269e767SBrooks Davis.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23*8269e767SBrooks Davis.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24*8269e767SBrooks Davis.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25*8269e767SBrooks Davis.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26*8269e767SBrooks Davis.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27*8269e767SBrooks Davis.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28*8269e767SBrooks Davis.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29*8269e767SBrooks Davis.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30*8269e767SBrooks Davis.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*8269e767SBrooks Davis.\"
32*8269e767SBrooks Davis.\"/
33*8269e767SBrooks Davis.Dd March 4, 2018
34*8269e767SBrooks Davis.Dt MSGGET 2
35*8269e767SBrooks Davis.Os
36*8269e767SBrooks Davis.Sh NAME
37*8269e767SBrooks Davis.Nm msgget
38*8269e767SBrooks Davis.Nd get message queue
39*8269e767SBrooks Davis.Sh LIBRARY
40*8269e767SBrooks Davis.Lb libc
41*8269e767SBrooks Davis.Sh SYNOPSIS
42*8269e767SBrooks Davis.In sys/msg.h
43*8269e767SBrooks Davis.Ft int
44*8269e767SBrooks Davis.Fn msgget "key_t key" "int msgflg"
45*8269e767SBrooks Davis.Sh DESCRIPTION
46*8269e767SBrooks DavisThe
47*8269e767SBrooks Davis.Fn msgget
48*8269e767SBrooks Davisfunction
49*8269e767SBrooks Davisreturns the message queue identifier associated with
50*8269e767SBrooks Davis.Fa key .
51*8269e767SBrooks DavisA message queue identifier is a unique integer greater than zero.
52*8269e767SBrooks Davis.Pp
53*8269e767SBrooks DavisA message queue is created if either
54*8269e767SBrooks Davis.Fa key
55*8269e767SBrooks Davisis equal to
56*8269e767SBrooks Davis.Dv IPC_PRIVATE ,
57*8269e767SBrooks Davisor
58*8269e767SBrooks Davis.Fa key
59*8269e767SBrooks Davisdoes not have a message queue identifier associated with it, and the
60*8269e767SBrooks Davis.Dv IPC_CREAT
61*8269e767SBrooks Davisbit is set in
62*8269e767SBrooks Davis.Fa msgflg .
63*8269e767SBrooks Davis.Pp
64*8269e767SBrooks DavisIf a new message queue is created, the data structure associated with it (the
65*8269e767SBrooks Davis.Va msqid_ds
66*8269e767SBrooks Davisstructure, see
67*8269e767SBrooks Davis.Xr msgctl 2 )
68*8269e767SBrooks Davisis initialized as follows:
69*8269e767SBrooks Davis.Bl -bullet
70*8269e767SBrooks Davis.It
71*8269e767SBrooks Davis.Va msg_perm.cuid
72*8269e767SBrooks Davisand
73*8269e767SBrooks Davis.Va msg_perm.uid
74*8269e767SBrooks Davisare set to the effective uid of the calling process.
75*8269e767SBrooks Davis.It
76*8269e767SBrooks Davis.Va msg_perm.gid
77*8269e767SBrooks Davisand
78*8269e767SBrooks Davis.Va msg_perm.cgid
79*8269e767SBrooks Davisare set to the effective gid of the calling process.
80*8269e767SBrooks Davis.It
81*8269e767SBrooks Davis.Va msg_perm.mode
82*8269e767SBrooks Davisis set to the lower 9 bits of
83*8269e767SBrooks Davis.Fa msgflg
84*8269e767SBrooks Daviswhich are set by ORing these constants:
85*8269e767SBrooks Davis.Bl -tag -width 0000
86*8269e767SBrooks Davis.It Dv 0400
87*8269e767SBrooks DavisRead access for user.
88*8269e767SBrooks Davis.It Dv 0200
89*8269e767SBrooks DavisWrite access for user.
90*8269e767SBrooks Davis.It Dv 0040
91*8269e767SBrooks DavisRead access for group.
92*8269e767SBrooks Davis.It Dv 0020
93*8269e767SBrooks DavisWrite access for group.
94*8269e767SBrooks Davis.It Dv 0004
95*8269e767SBrooks DavisRead access for other.
96*8269e767SBrooks Davis.It Dv 0002
97*8269e767SBrooks DavisWrite access for other.
98*8269e767SBrooks Davis.El
99*8269e767SBrooks Davis.It
100*8269e767SBrooks Davis.Va msg_cbytes ,
101*8269e767SBrooks Davis.Va msg_qnum ,
102*8269e767SBrooks Davis.Va msg_lspid ,
103*8269e767SBrooks Davis.Va msg_lrpid ,
104*8269e767SBrooks Davis.Va msg_rtime ,
105*8269e767SBrooks Davisand
106*8269e767SBrooks Davis.Va msg_stime
107*8269e767SBrooks Davisare set to 0.
108*8269e767SBrooks Davis.It
109*8269e767SBrooks Davis.Va msg_qbytes
110*8269e767SBrooks Davisis set to the system wide maximum value for the number of bytes in a queue
111*8269e767SBrooks Davis.Pf ( Dv MSGMNB ) .
112*8269e767SBrooks Davis.It
113*8269e767SBrooks Davis.Va msg_ctime
114*8269e767SBrooks Davisis set to the current time.
115*8269e767SBrooks Davis.El
116*8269e767SBrooks Davis.Sh RETURN VALUES
117*8269e767SBrooks DavisUpon successful completion a positive message queue identifier is returned.
118*8269e767SBrooks DavisOtherwise, -1 is returned and the global variable
119*8269e767SBrooks Davis.Va errno
120*8269e767SBrooks Davisis set to indicate the error.
121*8269e767SBrooks Davis.Sh ERRORS
122*8269e767SBrooks Davis.Bl -tag -width Er
123*8269e767SBrooks Davis.It Bq Er EACCES
124*8269e767SBrooks DavisA message queue is already associated with
125*8269e767SBrooks Davis.Fa key
126*8269e767SBrooks Davisand the caller has no permission to access it.
127*8269e767SBrooks Davis.It Bq Er EEXIST
128*8269e767SBrooks DavisBoth
129*8269e767SBrooks Davis.Dv IPC_CREAT
130*8269e767SBrooks Davisand
131*8269e767SBrooks Davis.Dv IPC_EXCL
132*8269e767SBrooks Davisare set in
133*8269e767SBrooks Davis.Fa msgflg ,
134*8269e767SBrooks Davisand a message queue is already associated with
135*8269e767SBrooks Davis.Fa key .
136*8269e767SBrooks Davis.It Bq Er ENOSPC
137*8269e767SBrooks DavisA new message queue could not be created because the system limit for
138*8269e767SBrooks Davisthe number of message queues has been reached.
139*8269e767SBrooks Davis.It Bq Er ENOENT
140*8269e767SBrooks Davis.Dv IPC_CREAT
141*8269e767SBrooks Daviswas not set in
142*8269e767SBrooks Davis.Fa msgflg
143*8269e767SBrooks Davisand no message queue associated with
144*8269e767SBrooks Davis.Fa key
145*8269e767SBrooks Daviswas found.
146*8269e767SBrooks Davis.El
147*8269e767SBrooks Davis.Sh SEE ALSO
148*8269e767SBrooks Davis.Xr msgctl 2 ,
149*8269e767SBrooks Davis.Xr msgrcv 2 ,
150*8269e767SBrooks Davis.Xr msgsnd 2
151*8269e767SBrooks Davis.Sh HISTORY
152*8269e767SBrooks DavisMessage queues appeared in the first release of
153*8269e767SBrooks Davis.At V .
154