1.\" $NetBSD: msgget.2,v 1.1 1995/10/16 23:49:19 jtc 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 50A message queue is created if either 51.Fa key 52is equal to IPC_PRIVATE, or 53.Fa key 54does not have a message queue identifier associated with it, and the IPC_CREAT 55bit is set in 56.Fa msgflg. 57 58If a new message queue is created, the data structure associated with it (the 59.Va msqid_ds 60structure, see 61.Xr msgctl 2 ) 62is initialized as follows: 63.Bl -bullet 64.It 65.Va msg_perm.cuid 66and 67.Va msg_perm.uid 68are set to the effective uid of the calling process. 69.It 70.Va msg_perm.gid 71and 72.Va msg_perm.cgid 73are set to the effective gid of the calling process. 74.It 75.Va msg_perm.mode 76is set to the lower 9 bits of 77.Fa msgflg . 78.It 79.Va msg_cbytes , 80.Va msg_qnum , 81.Va msg_lspid , 82.Va msg_lrpid , 83.Va msg_rtime , 84and 85.Va msg_stime 86are set to 0 87.It 88.Va msg_qbytes 89is set to the system wide maximum value for the number of bytes in a queue 90(MSGMNB). 91.It 92.Va msg_ctime 93is set to the current time. 94.El 95.Sh RETURN VALUES 96Upon successful completion a positive message queue identifier is returned. 97Otherwise, -1 is returned and the global variable 98.Va errno 99is set to indicate the error. 100.Sh ERRORS 101.Bl -tag -width Er 102.It Bq Er EACESS 103A message queue is already associated with 104.Fa key 105and the caller has no permission to access it. 106.It Bq Er EEXIST 107Both IPC_CREAT and IPC_EXCL are set in 108.Fa msgflg , 109and a message queue is already associated with 110.Fa key . 111.It Bq Er ENOSPC 112A new message queue could not be created because the system limit for 113the number of message queues has been reached. 114.It Bq Er ENOENT 115IPC_CREAT was not set in 116.Fa msgflg 117and no message queue associated with 118.Fa key 119was found. 120.El 121.Sh SEE ALSO 122.Xr msgctl 2 , 123.Xr msgrcv 2 , 124.Xr msgsnd 2 125.Sh HISTORY 126Message queues appeared in the first release of AT&T Unix System V. 127