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