1*2fe8fb19SBen Gras.\" $NetBSD: msgctl.2,v 1.15 2010/03/22 19:30:55 joerg Exp $ 2*2fe8fb19SBen Gras.\" 3*2fe8fb19SBen Gras.\" Copyright (c) 1995 Frank van der Linden 4*2fe8fb19SBen Gras.\" All rights reserved. 5*2fe8fb19SBen Gras.\" 6*2fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without 7*2fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions 8*2fe8fb19SBen Gras.\" are met: 9*2fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright 10*2fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer. 11*2fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright 12*2fe8fb19SBen Gras.\" notice, this list of conditions and the following disclaimer in the 13*2fe8fb19SBen Gras.\" documentation and/or other materials provided with the distribution. 14*2fe8fb19SBen Gras.\" 3. All advertising materials mentioning features or use of this software 15*2fe8fb19SBen Gras.\" must display the following acknowledgement: 16*2fe8fb19SBen Gras.\" This product includes software developed for the NetBSD Project 17*2fe8fb19SBen Gras.\" by Frank van der Linden 18*2fe8fb19SBen Gras.\" 4. The name of the author may not be used to endorse or promote products 19*2fe8fb19SBen Gras.\" derived from this software without specific prior written permission 20*2fe8fb19SBen Gras.\" 21*2fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22*2fe8fb19SBen Gras.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23*2fe8fb19SBen Gras.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24*2fe8fb19SBen Gras.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25*2fe8fb19SBen Gras.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26*2fe8fb19SBen Gras.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27*2fe8fb19SBen Gras.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28*2fe8fb19SBen Gras.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29*2fe8fb19SBen Gras.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30*2fe8fb19SBen Gras.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*2fe8fb19SBen Gras.\" 32*2fe8fb19SBen Gras.Dd August 25, 1999 33*2fe8fb19SBen Gras.Dt MSGCTL 2 34*2fe8fb19SBen Gras.Os 35*2fe8fb19SBen Gras.Sh NAME 36*2fe8fb19SBen Gras.Nm msgctl 37*2fe8fb19SBen Gras.Nd message control operations 38*2fe8fb19SBen Gras.Sh LIBRARY 39*2fe8fb19SBen Gras.Lb libc 40*2fe8fb19SBen Gras.Sh SYNOPSIS 41*2fe8fb19SBen Gras.In sys/msg.h 42*2fe8fb19SBen Gras.Ft int 43*2fe8fb19SBen Gras.Fn msgctl "int msqid" "int cmd" "struct msqid_ds *buf" 44*2fe8fb19SBen Gras.Sh DESCRIPTION 45*2fe8fb19SBen GrasThe 46*2fe8fb19SBen Gras.Fn msgctl 47*2fe8fb19SBen Grassystem call performs control operations on the message queue specified 48*2fe8fb19SBen Grasby 49*2fe8fb19SBen Gras.Fa msqid . 50*2fe8fb19SBen Gras.Pp 51*2fe8fb19SBen GrasEach message queue has a 52*2fe8fb19SBen Gras.Sy msqid_ds 53*2fe8fb19SBen Grasstructure associated with it which contains the following members: 54*2fe8fb19SBen Gras.Bd -literal 55*2fe8fb19SBen Gras struct ipc_perm msg_perm; /* msg queue permission bits */ 56*2fe8fb19SBen Gras msgqnum_t msg_qnum; /* # of msgs in the queue */ 57*2fe8fb19SBen Gras msglen_t msg_qbytes; /* max # of bytes on the queue */ 58*2fe8fb19SBen Gras pid_t msg_lspid; /* pid of last msgsnd() */ 59*2fe8fb19SBen Gras pid_t msg_lrpid; /* pid of last msgrcv() */ 60*2fe8fb19SBen Gras time_t msg_stime; /* time of last msgsnd() */ 61*2fe8fb19SBen Gras time_t msg_rtime; /* time of last msgrcv() */ 62*2fe8fb19SBen Gras time_t msg_ctime; /* time of last msgctl() */ 63*2fe8fb19SBen Gras.Ed 64*2fe8fb19SBen Gras.Pp 65*2fe8fb19SBen GrasThe 66*2fe8fb19SBen Gras.Sy ipc_perm 67*2fe8fb19SBen Grasstructure used inside the 68*2fe8fb19SBen Gras.Sy msgid_ds 69*2fe8fb19SBen Grasstructure is defined in 70*2fe8fb19SBen Gras.In sys/ipc.h 71*2fe8fb19SBen Grasand contains the following members: 72*2fe8fb19SBen Gras.Bd -literal 73*2fe8fb19SBen Gras uid_t cuid; /* creator user id */ 74*2fe8fb19SBen Gras gid_t cgid; /* creator group id */ 75*2fe8fb19SBen Gras uid_t uid; /* user id */ 76*2fe8fb19SBen Gras gid_t gid; /* group id */ 77*2fe8fb19SBen Gras mode_t mode; /* permission (lower 9 bits) */ 78*2fe8fb19SBen Gras.Ed 79*2fe8fb19SBen Gras.Pp 80*2fe8fb19SBen GrasThe operation to be performed by 81*2fe8fb19SBen Gras.Fn msgctl 82*2fe8fb19SBen Grasis specified in 83*2fe8fb19SBen Gras.Fa cmd 84*2fe8fb19SBen Grasand is one of: 85*2fe8fb19SBen Gras.Bl -tag -width IPC_RMIDX 86*2fe8fb19SBen Gras.It Dv IPC_STAT 87*2fe8fb19SBen GrasGather information about the message queue and place it in the 88*2fe8fb19SBen Grasstructure pointed to by 89*2fe8fb19SBen Gras.Fa buf . 90*2fe8fb19SBen Gras.It Dv IPC_SET 91*2fe8fb19SBen GrasSet the value of the 92*2fe8fb19SBen Gras.Va msg_perm.uid , 93*2fe8fb19SBen Gras.Va msg_perm.gid , 94*2fe8fb19SBen Gras.Va msg_perm.mode 95*2fe8fb19SBen Grasand 96*2fe8fb19SBen Gras.Va msg_qbytes 97*2fe8fb19SBen Grasfields in the structure associated with 98*2fe8fb19SBen Gras.Fa msqid . 99*2fe8fb19SBen GrasThe values are taken from the corresponding fields in the structure 100*2fe8fb19SBen Graspointed to by 101*2fe8fb19SBen Gras.Fa buf . 102*2fe8fb19SBen GrasThis operation can only be executed by the super-user, or a process that 103*2fe8fb19SBen Grashas an effective user id equal to either 104*2fe8fb19SBen Gras.Va msg_perm.cuid 105*2fe8fb19SBen Grasor 106*2fe8fb19SBen Gras.Va msg_perm.uid 107*2fe8fb19SBen Grasin the data structure associated with the message queue. 108*2fe8fb19SBen GrasThe value of 109*2fe8fb19SBen Gras.Va msg_qbytes 110*2fe8fb19SBen Grascan only be increased by the super-user. 111*2fe8fb19SBen GrasValues for 112*2fe8fb19SBen Gras.Va msg_qbytes 113*2fe8fb19SBen Grasthat exceed the system limit 114*2fe8fb19SBen Gras.Pf ( Dv MSGMNB 115*2fe8fb19SBen Grasfrom 116*2fe8fb19SBen Gras.In sys/msg.h ) 117*2fe8fb19SBen Grasare silently truncated to that limit. 118*2fe8fb19SBen Gras.It Dv IPC_RMID 119*2fe8fb19SBen GrasRemove the message queue specified by 120*2fe8fb19SBen Gras.Fa msqid 121*2fe8fb19SBen Grasand destroy the data associated with it. 122*2fe8fb19SBen GrasOnly the super-user or a process with an effective uid equal to the 123*2fe8fb19SBen Gras.Va msg_perm.cuid 124*2fe8fb19SBen Grasor 125*2fe8fb19SBen Gras.Va msg_perm.uid 126*2fe8fb19SBen Grasvalues in the data structure associated with the queue can do this. 127*2fe8fb19SBen Gras.El 128*2fe8fb19SBen Gras.Pp 129*2fe8fb19SBen GrasThe permission to read from or write to a message queue (see 130*2fe8fb19SBen Gras.Xr msgsnd 2 131*2fe8fb19SBen Grasand 132*2fe8fb19SBen Gras.Xr msgrcv 2 ) 133*2fe8fb19SBen Grasis determined by the 134*2fe8fb19SBen Gras.Va msg_perm.mode 135*2fe8fb19SBen Grasfield in the same way as is done with files (see 136*2fe8fb19SBen Gras.Xr chmod 2 ) , 137*2fe8fb19SBen Grasbut the effective uid can match either the 138*2fe8fb19SBen Gras.Va msg_perm.cuid 139*2fe8fb19SBen Grasfield or the 140*2fe8fb19SBen Gras.Va msg_perm.uid 141*2fe8fb19SBen Grasfield, and the 142*2fe8fb19SBen Graseffective gid can match either 143*2fe8fb19SBen Gras.Va msg_perm.cgid 144*2fe8fb19SBen Grasor 145*2fe8fb19SBen Gras.Va msg_perm.gid . 146*2fe8fb19SBen Gras.Sh RETURN VALUES 147*2fe8fb19SBen GrasUpon successful completion, a value of 0 is returned. 148*2fe8fb19SBen GrasOtherwise, \-1 is returned and the global variable 149*2fe8fb19SBen Gras.Va errno 150*2fe8fb19SBen Grasis set to indicate the error. 151*2fe8fb19SBen Gras.Sh ERRORS 152*2fe8fb19SBen Gras.Fn msgctl 153*2fe8fb19SBen Graswill fail if: 154*2fe8fb19SBen Gras.Bl -tag -width Er 155*2fe8fb19SBen Gras.It Bq Er EPERM 156*2fe8fb19SBen Gras.Fa cmd 157*2fe8fb19SBen Grasis equal to 158*2fe8fb19SBen Gras.Dv IPC_SET 159*2fe8fb19SBen Grasor 160*2fe8fb19SBen Gras.Dv IPC_RMID 161*2fe8fb19SBen Grasand the caller is not the super-user, nor does 162*2fe8fb19SBen Grasthe effective uid match either the 163*2fe8fb19SBen Gras.Va msg_perm.uid 164*2fe8fb19SBen Grasor 165*2fe8fb19SBen Gras.Va msg_perm.cuid 166*2fe8fb19SBen Grasfields of the data structure associated with the message queue. 167*2fe8fb19SBen Gras.Pp 168*2fe8fb19SBen GrasAn attempt was made to increase the value of 169*2fe8fb19SBen Gras.Va msg_qbytes 170*2fe8fb19SBen Grasthrough 171*2fe8fb19SBen Gras.Dv IPC_SET , 172*2fe8fb19SBen Grasbut the caller is not the super-user. 173*2fe8fb19SBen Gras.It Bq Er EACCES 174*2fe8fb19SBen Gras.Fa cmd 175*2fe8fb19SBen Grasis 176*2fe8fb19SBen Gras.Dv IPC_STAT 177*2fe8fb19SBen Grasand the caller has no read permission for this message queue. 178*2fe8fb19SBen Gras.It Bq Er EINVAL 179*2fe8fb19SBen Gras.Fa msqid 180*2fe8fb19SBen Grasis not a valid message queue identifier. 181*2fe8fb19SBen Gras.Pp 182*2fe8fb19SBen Gras.Fa cmd 183*2fe8fb19SBen Grasis not a valid command. 184*2fe8fb19SBen Gras.It Bq Er EFAULT 185*2fe8fb19SBen Gras.Fa buf 186*2fe8fb19SBen Grasspecifies an invalid address. 187*2fe8fb19SBen Gras.El 188*2fe8fb19SBen Gras.Sh SEE ALSO 189*2fe8fb19SBen Gras.Xr msgget 2 , 190*2fe8fb19SBen Gras.Xr msgrcv 2 , 191*2fe8fb19SBen Gras.Xr msgsnd 2 192*2fe8fb19SBen Gras.Sh STANDARDS 193*2fe8fb19SBen GrasThe 194*2fe8fb19SBen Gras.Nm 195*2fe8fb19SBen Grassystem call conforms to 196*2fe8fb19SBen Gras.St -xsh5 . 197*2fe8fb19SBen Gras.Sh HISTORY 198*2fe8fb19SBen GrasMessage queues appeared in the first release of 199*2fe8fb19SBen Gras.At V . 200