182657471SMarkus Pfeiffer.\" $NetBSD: msgget.2,v 1.1 1995/10/16 23:49:19 jtc Exp $ 282657471SMarkus Pfeiffer.\" 382657471SMarkus Pfeiffer.\" Copyright (c) 1995 Frank van der Linden 482657471SMarkus Pfeiffer.\" All rights reserved. 582657471SMarkus Pfeiffer.\" 682657471SMarkus Pfeiffer.\" Redistribution and use in source and binary forms, with or without 782657471SMarkus Pfeiffer.\" modification, are permitted provided that the following conditions 882657471SMarkus Pfeiffer.\" are met: 982657471SMarkus Pfeiffer.\" 1. Redistributions of source code must retain the above copyright 1082657471SMarkus Pfeiffer.\" notice, this list of conditions and the following disclaimer. 1182657471SMarkus Pfeiffer.\" 2. Redistributions in binary form must reproduce the above copyright 1282657471SMarkus Pfeiffer.\" notice, this list of conditions and the following disclaimer in the 1382657471SMarkus Pfeiffer.\" documentation and/or other materials provided with the distribution. 1482657471SMarkus Pfeiffer.\" 3. All advertising materials mentioning features or use of this software 1582657471SMarkus Pfeiffer.\" must display the following acknowledgement: 1682657471SMarkus Pfeiffer.\" This product includes software developed for the NetBSD Project 1782657471SMarkus Pfeiffer.\" by Frank van der Linden 1882657471SMarkus Pfeiffer.\" 4. The name of the author may not be used to endorse or promote products 1982657471SMarkus Pfeiffer.\" derived from this software without specific prior written permission 2082657471SMarkus Pfeiffer.\" 2182657471SMarkus Pfeiffer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2282657471SMarkus Pfeiffer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2382657471SMarkus Pfeiffer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2482657471SMarkus Pfeiffer.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2582657471SMarkus Pfeiffer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2682657471SMarkus Pfeiffer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2782657471SMarkus Pfeiffer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2882657471SMarkus Pfeiffer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2982657471SMarkus Pfeiffer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 3082657471SMarkus Pfeiffer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3182657471SMarkus Pfeiffer.\" 3282657471SMarkus Pfeiffer.\" $FreeBSD: src/lib/libc/gen/msgget.3,v 1.7.2.5 2003/03/15 15:11:05 trhodes Exp $ 3382657471SMarkus Pfeiffer.\" 34*8e1dfd3aSSascha Wildner.Dd January 4, 2014 3582657471SMarkus Pfeiffer.Dt MSGGET 2 3682657471SMarkus Pfeiffer.Os 3782657471SMarkus Pfeiffer.Sh NAME 3882657471SMarkus Pfeiffer.Nm msgget 3982657471SMarkus Pfeiffer.Nd get message queue 4082657471SMarkus Pfeiffer.Sh LIBRARY 4182657471SMarkus Pfeiffer.Lb libc 4282657471SMarkus Pfeiffer.Sh SYNOPSIS 4382657471SMarkus Pfeiffer.In sys/types.h 4482657471SMarkus Pfeiffer.In sys/ipc.h 4582657471SMarkus Pfeiffer.In sys/msg.h 4682657471SMarkus Pfeiffer.Ft int 4782657471SMarkus Pfeiffer.Fn msgget "key_t key" "int msgflg" 4882657471SMarkus Pfeiffer.Sh DESCRIPTION 4982657471SMarkus PfeifferThe 5082657471SMarkus Pfeiffer.Fn msgget 5182657471SMarkus Pfeiffersystem call 5282657471SMarkus Pfeifferreturns the message queue identifier associated with 5382657471SMarkus Pfeiffer.Fa key . 5482657471SMarkus PfeifferA message queue identifier is a unique integer greater than zero. 5582657471SMarkus Pfeiffer.Pp 5682657471SMarkus PfeifferA message queue is created if either 5782657471SMarkus Pfeiffer.Fa key 5882657471SMarkus Pfeifferis equal to 5982657471SMarkus Pfeiffer.Dv IPC_PRIVATE , 6082657471SMarkus Pfeifferor 6182657471SMarkus Pfeiffer.Fa key 6282657471SMarkus Pfeifferdoes not have a message queue identifier associated with it, and the 6382657471SMarkus Pfeiffer.Dv IPC_CREAT 6482657471SMarkus Pfeifferbit is set in 6582657471SMarkus Pfeiffer.Fa msgflg . 6682657471SMarkus Pfeiffer.Pp 6782657471SMarkus PfeifferIf a new message queue is created, the data structure associated with it (the 6882657471SMarkus Pfeiffer.Va msqid_ds 6982657471SMarkus Pfeifferstructure, see 7082657471SMarkus Pfeiffer.Xr msgctl 2 ) 7182657471SMarkus Pfeifferis initialized as follows: 7282657471SMarkus Pfeiffer.Bl -bullet 7382657471SMarkus Pfeiffer.It 7482657471SMarkus Pfeiffer.Va msg_perm.cuid 7582657471SMarkus Pfeifferand 7682657471SMarkus Pfeiffer.Va msg_perm.uid 7782657471SMarkus Pfeifferare set to the effective uid of the calling process. 7882657471SMarkus Pfeiffer.It 7982657471SMarkus Pfeiffer.Va msg_perm.gid 8082657471SMarkus Pfeifferand 8182657471SMarkus Pfeiffer.Va msg_perm.cgid 8282657471SMarkus Pfeifferare set to the effective gid of the calling process. 8382657471SMarkus Pfeiffer.It 8482657471SMarkus Pfeiffer.Va msg_perm.mode 8582657471SMarkus Pfeifferis set to the lower 9 bits of 8682657471SMarkus Pfeiffer.Fa msgflg . 8782657471SMarkus Pfeiffer.It 8882657471SMarkus Pfeiffer.Va msg_cbytes , 8982657471SMarkus Pfeiffer.Va msg_qnum , 9082657471SMarkus Pfeiffer.Va msg_lspid , 9182657471SMarkus Pfeiffer.Va msg_lrpid , 9282657471SMarkus Pfeiffer.Va msg_rtime , 9382657471SMarkus Pfeifferand 9482657471SMarkus Pfeiffer.Va msg_stime 9582657471SMarkus Pfeifferare set to 0. 9682657471SMarkus Pfeiffer.It 9782657471SMarkus Pfeiffer.Va msg_qbytes 9882657471SMarkus Pfeifferis set to the system wide maximum value for the number of bytes in a queue 9982657471SMarkus Pfeiffer.Pf ( Dv MSGMNB ) . 10082657471SMarkus Pfeiffer.It 10182657471SMarkus Pfeiffer.Va msg_ctime 10282657471SMarkus Pfeifferis set to the current time. 10382657471SMarkus Pfeiffer.El 10482657471SMarkus Pfeiffer.Sh RETURN VALUES 10582657471SMarkus PfeifferUpon successful completion a positive message queue identifier is returned. 10682657471SMarkus PfeifferOtherwise, -1 is returned and the global variable 10782657471SMarkus Pfeiffer.Va errno 10882657471SMarkus Pfeifferis set to indicate the error. 10982657471SMarkus Pfeiffer.Sh ENVIRONMENT 11082657471SMarkus PfeifferThe XSI Interprocess Communication family of functions is also available 11182657471SMarkus Pfeifferas an implementation in userspace. 11282657471SMarkus PfeifferTo use it, the 11382657471SMarkus Pfeiffer.Xr sysvipcd 8 11482657471SMarkus Pfeifferdaemon has to be running. 11582657471SMarkus Pfeiffer.Pp 11682657471SMarkus PfeifferIf the 11782657471SMarkus Pfeiffer.Ev USR_SYSVIPC 11882657471SMarkus Pfeiffervariable is set in a process' environment, the process and its children 11982657471SMarkus Pfeifferwill use the userspace implementation. 12082657471SMarkus Pfeiffer.Sh ERRORS 12182657471SMarkus Pfeiffer.Bl -tag -width Er 12282657471SMarkus Pfeiffer.It Bq Er EACCES 12382657471SMarkus PfeifferA message queue is already associated with 12482657471SMarkus Pfeiffer.Fa key 12582657471SMarkus Pfeifferand the caller has no permission to access it. 12682657471SMarkus Pfeiffer.It Bq Er EEXIST 12782657471SMarkus PfeifferBoth 12882657471SMarkus Pfeiffer.Dv IPC_CREAT 12982657471SMarkus Pfeifferand 13082657471SMarkus Pfeiffer.Dv IPC_EXCL 13182657471SMarkus Pfeifferare set in 13282657471SMarkus Pfeiffer.Fa msgflg , 13382657471SMarkus Pfeifferand a message queue is already associated with 13482657471SMarkus Pfeiffer.Fa key . 13582657471SMarkus Pfeiffer.It Bq Er ENOSPC 13682657471SMarkus PfeifferA new message queue could not be created because the system limit for 13782657471SMarkus Pfeifferthe number of message queues has been reached. 13882657471SMarkus Pfeiffer.It Bq Er ENOENT 13982657471SMarkus Pfeiffer.Dv IPC_CREAT 14082657471SMarkus Pfeifferwas not set in 14182657471SMarkus Pfeiffer.Fa msgflg 14282657471SMarkus Pfeifferand no message queue associated with 14382657471SMarkus Pfeiffer.Fa key 14482657471SMarkus Pfeifferwas found. 14582657471SMarkus Pfeiffer.El 14682657471SMarkus Pfeiffer.Sh SEE ALSO 14782657471SMarkus Pfeiffer.Xr msgctl 2 , 14882657471SMarkus Pfeiffer.Xr msgrcv 2 , 14982657471SMarkus Pfeiffer.Xr msgsnd 2 15082657471SMarkus Pfeiffer.Sh HISTORY 15182657471SMarkus PfeifferMessage queues appeared in the first release of 15282657471SMarkus Pfeiffer.At V . 15382657471SMarkus Pfeiffer.Sh AUTHORS 15482657471SMarkus Pfeiffer.An -nosplit 15582657471SMarkus PfeifferThe 15682657471SMarkus Pfeiffer.Dx 15782657471SMarkus Pfeifferspecific userspace implementation (see 15882657471SMarkus Pfeiffer.Sx ENVIRONMENT ) 15982657471SMarkus Pfeifferwas written by 16082657471SMarkus Pfeiffer.An Larisa Grigore . 161