]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/mq_send.3
Minor changes
[thirdparty/man-pages.git] / man3 / mq_send.3
CommitLineData
80a99f39
MK
1'\" t
2.\" Hey Emacs! This file is -*- nroff -*- source.
3.\"
4.\" Copyright (C) 2006 Michael Kerrisk <mtk-manpages@gmx.net>
5.\"
6.\" Permission is granted to make and distribute verbatim copies of this
7.\" manual provided the copyright notice and this permission notice are
8.\" preserved on all copies.
9.\"
10.\" Permission is granted to copy and distribute modified versions of this
11.\" manual under the conditions for verbatim copying, provided that the
12.\" entire resulting derived work is distributed under the terms of a
13.\" permission notice identical to this one.
c13182ef 14.\"
80a99f39
MK
15.\" Since the Linux kernel and libraries are constantly changing, this
16.\" manual page may be incorrect or out-of-date. The author(s) assume no
17.\" responsibility for errors or omissions, or for damages resulting from
c13182ef
MK
18.\" the use of the information contained herein.
19.\"
80a99f39
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
d9343c5c 23.TH MQ_SEND 3 2006-02-25 "Linux" "Linux Programmer's Manual"
80a99f39
MK
24.SH NAME
25mq_send, mq_timedsend \- send a message to a message queue
26.SH SYNOPSIS
27.nf
28.B #include <mqueue.h>
29.sp
30.BI "mqd_t mq_send(mqd_t " mqdes ", const char *" msg_ptr ,
b9f02710 31.BI " size_t " msg_len ", unsigned " msg_prio );
80a99f39
MK
32.sp
33.B #define _XOPEN_SOURCE 600
34.B #include <time.h>
35.B #include <mqueue.h>
36.sp
37.BI "mqd_t mq_timedsend(mqd_t " mqdes ", const char *" msg_ptr ,
b9f02710
MK
38.BI " size_t " msg_len ", unsigned " msg_prio ,
39.BI " const struct timespec *" abs_timeout );
80a99f39
MK
40.fi
41.SH DESCRIPTION
42.BR mq_send ()
43adds the message pointed to by
44.IR msg_ptr
45to the message queue referred to by the descriptor
46.IR mqdes .
c13182ef 47The
80a99f39
MK
48.I msg_len
49argument specifies the length of the message pointed to by
50.IR msg_ptr ;
51this length must be less than or equal to the queue's
52.I mq_msgsize
53attribute.
54Zero-length messages are allowed.
55
c13182ef 56The
80a99f39 57.I msg_prio
c13182ef 58argument is a non-negative integer that specifies the priority
80a99f39 59of this message.
c13182ef
MK
60Messages are placed on the queue in decreasing order of priority,
61with newer messages of the same priority being placed after
80a99f39
MK
62older messages with the same priority.
63
c13182ef 64If the message queue is already full
80a99f39
MK
65(i.e., the number of messages on the queue equals the queue's
66.I mq_maxmsg
67attribute), then, by default,
68.BR mq_send ()
c13182ef 69blocks until sufficient space becomes available to allow the message
80a99f39 70to be queued, or until the call is interrupted by a signal handler.
c13182ef 71If the
80a99f39
MK
72.B O_NONBLOCK
73flag is enabled for the message queue description,
74then the call instead fails immediately with the error
75.BR EAGAIN .
76
77.BR mq_timedsend ()
78behaves just like
79.BR mq_send (),
80except that if the queue is full and the
81.B O_NONBLOCK
82flag is not enabled for the message queue description, then
83.I abs_timeout
c13182ef 84points to a structure which specifies a ceiling on the time for which
80a99f39
MK
85the call will block.
86This ceiling is an absolute timeout in seconds and nanoseconds
87since the Epoch (midnight on the morning of 1 January 1970),
88specified in the following structure:
89.sp
90.RS
91.nf
92struct timespec {
93 time_t tv_sec; /* seconds */
94 long tv_nsec; /* nanoseconds */
95};
96
97.fi
98.RE
99If the message queue is full,
100and the timeout has already expired by the time of the call,
101.BR mq_timedsend ()
102returns immediately.
103.SH RETURN VALUE
104On success,
105.BR mq_send ()
106and
107.BR mq_timedsend ()
108return zero; on error, \-1 is returned, with
c13182ef 109.I errno
80a99f39
MK
110set to indicate the error.
111.SH ERRORS
112.TP
113.B EAGAIN
114The queue was empty, and the
115.B O_NONBLOCK
116flag was set for the message queue description referred to by
117.IR mqdes .
118.TP
119.B EBADF
c13182ef 120The descriptor specified in
80a99f39
MK
121.I mqdes
122was invalid.
123.TP
124.B EMSGSIZE
c13182ef
MK
125.IR msg_len
126was greater than the
80a99f39
MK
127.I mq_msgsize
128attribute of the message queue.
129.TP
130.B EINTR
131The call was interrupted by a signal handler.
132.TP
133.B EINVAL
c13182ef 134The call would have blocked, and
80a99f39
MK
135.I abs_timeout
136was invalid, either because
137.I tv_sec
138was less than zero, or because
c13182ef 139.I tv_nsec
80a99f39
MK
140was less than zero or greater than 1000 million.
141.TP
142.B ETIMEDOUT
143The call timed out before a message could be transferred.
144.SH CONFORMING TO
145POSIX.1-2001.
146.SH "SEE ALSO"
147.BR mq_close (3),
148.BR mq_getattr (3),
149.BR mq_notify (3),
150.BR mq_open (3),
151.BR mq_receive (3),
152.BR mq_unlink (3),
0a90178c 153.BR feature_test_macros (7),
80a99f39 154.BR mq_overview (7)