[BACK]Return to msgsnd.2 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / sys

File: [cvs.NetBSD.org] / src / lib / libc / sys / msgsnd.2 (download)

Revision 1.18, Fri Apr 30 04:06:20 2010 UTC (13 years, 11 months ago) by jruoho
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Branch point for: yamt-pagecache, tls-maxphys, netbsd-6
Changes since 1.17: +20 -12 lines

Small improvements to wording and markup.

.\"	$NetBSD: msgsnd.2,v 1.18 2010/04/30 04:06:20 jruoho Exp $
.\"
.\" 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.
.\"
.Dd April 30, 2010
.Dt MSGSND 2
.Os
.Sh NAME
.Nm msgsnd
.Nd send a message to a message queue
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In sys/msg.h
.Ft int
.Fn msgsnd "int msqid" "const void *msgp" "size_t msgsz" "int msgflg"
.Sh DESCRIPTION
The
.Fn msgsnd
function sends a message from the message queue specified in
.Fa msqid .
The
.Fa msgp
argument is a pointer to a user-defined structure containing the message.
This structure must contain a first field of type
.Vt long
that will indicate the user-defined type of the message.
The remaining fields will contain the contents of the message.
The following is an example of what this user-defined
structure might look like:
.Bd -literal -offset indent
struct mymsg {
    long mtype;    /* message type */
    char mtext[1]; /* body of message */
};
.Ed
.Pp
The
.Va mtype
field is an integer greater than 0 that can
be used for selecting messages (see
.Xr msgrcv 2 ) .
The
.Va mtext
field is an array of bytes, with size up to the system limit
.Dv MSGMAX .
.Pp
If the number of bytes already on the message queue plus
.Fa msgsz
is greater than the maximum number of bytes in the message queue
.Pf ( Va msg_qbytes ,
see
.Xr msgctl 2 ) ,
or if 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
has
.Dv IPC_NOWAIT
mask set in it, the call will return immediately.
If
.Fa msgflg
does not have
.Dv IPC_NOWAIT
set in it, the call will block until:
.Bl -bullet -offset indent
.It
The condition which caused the call to block no longer exists.
The message was sent.
.It
The message queue is removed, in which case \-1 will be returned and
.Va errno
set to
.Er EINVAL .
.It
The caller catches a signal.
The call returns with
.Va errno
set to
.Er EINTR .
.El
.Pp
After a successful call, the data structure associated with the message
queue is updated in the following way:
.Bl -bullet -offset indent
.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
Upon successful completion, 0 is returned.
Otherwise, \-1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
.Fn msgsnd
will fail if:
.Bl -tag -width Er
.It Bq Er EACCES
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
system, and
.Dv IPC_NOWAIT
was set in
.Fa msgflg .
.It Bq Er EFAULT
.Fa msgp
points to an invalid address.
.It Bq Er EINTR
The system call was interrupted by the delivery of a signal.
.It Bq Er EINVAL
The
.Fa msqid
argument is not a valid message queue identifier,
or the value of
.Fa mtype
is less than 1.
.Pp
The message queue was removed while
.Fn msgsnd
was waiting for a resource to become available in order to deliver the
message.
.Pp
The
.Fa msgsz
argument is greater than
.Va msg_qbytes
or
.Dv SSIZE_MAX .
.El
.Sh SEE ALSO
.Xr msgctl 2 ,
.Xr msgget 2 ,
.Xr msgrcv 2
.Sh STANDARDS
The
.Nm
system call conforms to
.St -xsh5
and
.St -p1003.1-2001 .
.Sh HISTORY
Message queues appeared in the first release of
.At V .