2000-10-30 13:23:19 +00:00
|
|
|
.\" $NetBSD: msgsnd.2,v 1.1 1995/10/16 23:49:24 jtc Exp $
|
1996-02-12 07:03:24 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1995 Frank van der Linden
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed for the NetBSD Project
|
|
|
|
.\" by Frank van der Linden
|
|
|
|
.\" 4. The name of the author may not be used to endorse or promote products
|
|
|
|
.\" derived from this software without specific prior written permission
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2000-01-13 14:27:44 +00:00
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1997-11-23 17:58:55 +00:00
|
|
|
.\"
|
2006-10-12 11:42:41 +00:00
|
|
|
.Dd October 12, 2006
|
1996-02-12 07:03:24 +00:00
|
|
|
.Dt MSGSND 3
|
2001-07-10 13:41:46 +00:00
|
|
|
.Os
|
1996-02-12 07:03:24 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm msgsnd
|
|
|
|
.Nd send a message to a message queue
|
2000-04-21 09:42:15 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
1996-02-12 07:03:24 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/types.h
|
|
|
|
.In sys/ipc.h
|
|
|
|
.In sys/msg.h
|
1996-02-12 07:03:24 +00:00
|
|
|
.Ft int
|
2003-01-26 20:09:34 +00:00
|
|
|
.Fn msgsnd "int msqid" "const void *msgp" "size_t msgsz" "int msgflg"
|
1996-02-12 07:03:24 +00:00
|
|
|
.Sh DESCRIPTION
|
2000-10-30 13:23:19 +00:00
|
|
|
The
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fn msgsnd
|
2000-01-13 14:26:23 +00:00
|
|
|
function sends a message to the message queue specified in
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fa msqid .
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fa msgp
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
2000-03-02 09:14:21 +00:00
|
|
|
points to a structure containing the message.
|
|
|
|
This structure should
|
1996-02-12 07:03:24 +00:00
|
|
|
consist of the following members:
|
|
|
|
.Bd -literal
|
|
|
|
long mtype; /* message type */
|
|
|
|
char mtext[1]; /* body of message */
|
|
|
|
.Ed
|
1997-03-21 20:46:30 +00:00
|
|
|
.Pp
|
1996-02-12 07:03:24 +00:00
|
|
|
.Va mtype
|
|
|
|
is an integer greater than 0 that can be used for selecting messages (see
|
|
|
|
.Xr msgrcv 3 ) ,
|
2000-10-30 13:23:19 +00:00
|
|
|
.Va mtext
|
2006-10-12 11:42:41 +00:00
|
|
|
is an array of
|
|
|
|
.Fa msgsz
|
|
|
|
bytes.
|
|
|
|
The argument
|
|
|
|
.Fa msgsz
|
|
|
|
can range from 0 to a system-imposed maximum,
|
|
|
|
.Dv MSGMAX .
|
1997-03-21 20:46:30 +00:00
|
|
|
.Pp
|
1996-02-12 07:03:24 +00:00
|
|
|
If the number of bytes already on the message queue plus
|
|
|
|
.Fa msgsz
|
1997-03-21 20:46:30 +00:00
|
|
|
is bigger than the maximum number of bytes on the message queue
|
|
|
|
.Pf ( Va msg_qbytes ,
|
1996-02-12 07:03:24 +00:00
|
|
|
see
|
|
|
|
.Xr msgctl 3 ) ,
|
|
|
|
or the number of messages on all queues system-wide is already equal to
|
|
|
|
the system limit,
|
|
|
|
.Fa msgflg
|
|
|
|
determines the action of
|
|
|
|
.Fn msgsnd .
|
|
|
|
If
|
|
|
|
.Fa msgflg
|
1997-03-21 20:46:30 +00:00
|
|
|
has
|
|
|
|
.Dv IPC_NOWAIT
|
2000-03-02 09:14:21 +00:00
|
|
|
mask set in it, the call will return immediately.
|
|
|
|
If
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fa msgflg
|
1997-03-21 20:46:30 +00:00
|
|
|
does not have
|
|
|
|
.Dv IPC_NOWAIT
|
|
|
|
set in it, the call will block until:
|
1996-02-12 07:03:24 +00:00
|
|
|
.Bl -bullet
|
|
|
|
.It
|
|
|
|
The condition which caused the call to block does no longer exist.
|
|
|
|
The message will be sent.
|
|
|
|
.It
|
|
|
|
The message queue is removed, in which case -1 will be returned, and
|
|
|
|
.Va errno
|
1997-03-21 20:46:30 +00:00
|
|
|
is set to
|
|
|
|
.Er EINVAL .
|
1996-02-12 07:03:24 +00:00
|
|
|
.It
|
2000-03-02 09:14:21 +00:00
|
|
|
The caller catches a signal.
|
|
|
|
The call returns with
|
1996-02-12 07:03:24 +00:00
|
|
|
.Va errno
|
1997-03-21 20:46:30 +00:00
|
|
|
set to
|
|
|
|
.Er EINTR .
|
1996-02-12 07:03:24 +00:00
|
|
|
.El
|
1997-03-21 20:46:30 +00:00
|
|
|
.Pp
|
1996-02-12 07:03:24 +00:00
|
|
|
After a successful call, the data structure associated with the message
|
|
|
|
queue is updated in the following way:
|
|
|
|
.Bl -bullet
|
|
|
|
.It
|
|
|
|
.Va msg_cbytes
|
|
|
|
is incremented by the size of the message.
|
|
|
|
.It
|
|
|
|
.Va msg_qnum
|
|
|
|
is incremented by 1.
|
|
|
|
.It
|
|
|
|
.Va msg_lspid
|
|
|
|
is set to the pid of the calling process.
|
|
|
|
.It
|
|
|
|
.Va msg_stime
|
|
|
|
is set to the current time.
|
|
|
|
.El
|
|
|
|
.Sh RETURN VALUES
|
2001-08-09 13:32:13 +00:00
|
|
|
.Rv -std msgsnd
|
1996-02-12 07:03:24 +00:00
|
|
|
.Sh ERRORS
|
2002-12-18 10:13:54 +00:00
|
|
|
The
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fn msgsnd
|
2002-12-18 10:13:54 +00:00
|
|
|
function
|
1996-02-12 07:03:24 +00:00
|
|
|
will fail if:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EINVAL
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fa msqid
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
1996-02-12 07:03:24 +00:00
|
|
|
is not a valid message queue identifier
|
1997-03-21 20:46:30 +00:00
|
|
|
.Pp
|
1996-02-12 07:03:24 +00:00
|
|
|
The message queue was removed while
|
|
|
|
.Fn msgsnd
|
|
|
|
was waiting for a resource to become available in order to deliver the
|
|
|
|
message.
|
1997-03-21 20:46:30 +00:00
|
|
|
.Pp
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fa msgsz
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
2006-10-12 11:42:41 +00:00
|
|
|
is greater than
|
1996-02-12 07:03:24 +00:00
|
|
|
.Va msg_qbytes .
|
1999-07-26 11:39:02 +00:00
|
|
|
.Pp
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
1999-07-26 11:39:02 +00:00
|
|
|
.Fa mtype
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
1999-07-26 11:39:02 +00:00
|
|
|
is not greater than 0.
|
1997-11-23 17:58:55 +00:00
|
|
|
.It Bq Er EACCES
|
1996-02-12 07:03:24 +00:00
|
|
|
The calling process does not have write access to the message queue.
|
|
|
|
.It Bq Er EAGAIN
|
|
|
|
There was no space for this message either on the queue, or in the whole
|
1997-03-21 20:46:30 +00:00
|
|
|
system, and
|
|
|
|
.Dv IPC_NOWAIT
|
|
|
|
was set in
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fa msgflg .
|
|
|
|
.It Bq Er EFAULT
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
1996-02-12 07:03:24 +00:00
|
|
|
.Fa msgp
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
1996-02-12 07:03:24 +00:00
|
|
|
points to an invalid address.
|
|
|
|
.It Bq Er EINTR
|
|
|
|
The system call was interrupted by the delivery of a signal.
|
|
|
|
.El
|
2005-01-20 09:17:07 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
Message queues appeared in the first release of AT&T Unix System V.
|
1996-02-12 07:03:24 +00:00
|
|
|
.Sh BUGS
|
2001-08-13 17:00:36 +00:00
|
|
|
.Nx
|
1997-03-21 20:46:30 +00:00
|
|
|
and
|
2000-11-14 11:20:58 +00:00
|
|
|
.Fx
|
1997-03-21 20:46:30 +00:00
|
|
|
do not define the
|
|
|
|
.Er EIDRM
|
|
|
|
error value, which should be used
|
1996-02-12 07:03:24 +00:00
|
|
|
in the case of a removed message queue.
|