1333 High kernel cpu usage & dtrace hang on idle system
[illumos-gate.git] / usr / src / man / man2 / putmsg.2
blob85d98f8b8f1ed0d78b7218c7857601321e58d414
1 '\" te
2 .\" Copyright 1989 AT&T.  Copyright (c) 1996, Sun Microsystems, Inc.  All Rights Reserved.  Portions Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH PUTMSG 2 "Nov 1, 2003"
11 .SH NAME
12 putmsg, putpmsg \- send a message on a stream
13 .SH SYNOPSIS
14 .LP
15 .nf
16 #include <stropts.h>
18 \fBint\fR \fBputmsg\fR(\fBint\fR \fIfildes\fR, \fBconst struct strbuf *\fR\fIctlptr\fR,
19      \fBconst struct strbuf *\fR\fIdataptr\fR, \fBint\fR \fIflags\fR);
20 .fi
22 .LP
23 .nf
24 \fBint\fR \fBputpmsg\fR(\fBint\fR \fIfildes\fR, \fBconst struct strbuf *\fR\fIctlptr\fR,
25      \fBconst struct strbuf *\fR\fIdataptr\fR,\fBint\fR \fIband\fR, \fBint\fR \fIflags\fR);
26 .fi
28 .SH DESCRIPTION
29 .sp
30 .LP
31 The \fBputmsg()\fR function creates a message  from user-specified buffer(s)
32 and sends the message to a streams file. The message may contain either a data
33 part, a control part, or both. The data and control parts to be sent are
34 distinguished by placement in separate  buffers, as described below. The
35 semantics of each part is defined by the streams module that receives  the
36 message.
37 .sp
38 .LP
39 The \fBputpmsg()\fR function does the same thing as \fBputmsg()\fR, but
40 provides the user the ability to send messages in different priority bands.
41 Except where noted, all information pertaining to \fBputmsg()\fR also pertains
42 to \fBputpmsg()\fR.
43 .sp
44 .LP
45 The \fIfildes\fR argument specifies a file descriptor referencing an open
46 stream. The \fIctlptr\fR and \fIdataptr\fR arguments each point to a
47 \fBstrbuf\fR structure, which contains the following members:
48 .sp
49 .in +2
50 .nf
51 int      maxlen;     /* not used here */
52 int      len;        /* length of data */
53 void     *buf;       /* ptr to buffer */
54 .fi
55 .in -2
57 .sp
58 .LP
59 The \fIctlptr\fR argument points to the structure describing the control part,
60 if any, to be included in the message. The \fBbuf\fR member in the \fBstrbuf\fR
61 structure points to the buffer where the control information resides, and the
62 \fBlen\fR member indicates the number of bytes to be sent. The \fBmaxlen\fR
63 member is not used in \fBputmsg()\fR (see \fBgetmsg\fR(2)). In a similar
64 manner, \fIdataptr\fR specifies the data, if any, to be included in  the
65 message.  The \fIflags\fR argument indicates what type of message should be
66 sent and is described later.
67 .sp
68 .LP
69 To send the data part of a message, \fIdataptr\fR must not be \fINULL\fR, and
70 the \fBlen\fR member of \fIdataptr\fR must have a value of 0 or greater. To
71 send the control part of a message, the corresponding values must be set for
72 \fIctlptr\fR. No data (control) part is sent if either \fIdataptr\fR
73 (\fIctlptr\fR) is  \fINULL\fR or the \fBlen\fR member of \fIdataptr\fR
74 (\fIctlptr\fR) is negative.
75 .sp
76 .LP
77 For \fBputmsg()\fR, if a control part is specified, and \fIflags\fR is set to
78 \fBRS_HIPRI\fR, a high priority message is sent. If no control part is
79 specified, and \fIflags\fR is set to \fBRS_HIPRI\fR, \fBputmsg()\fR fails and
80 sets \fBerrno\fR to \fBEINVAL\fR. If \fIflags\fR is set to 0, a normal
81 (non-priority) message is sent. If no control part and no data part are
82 specified, and \fIflags\fR is set to 0,  no message is sent, and 0 is returned.
83 .sp
84 .LP
85 The stream head guarantees that the control part of a message generated by
86 \fBputmsg()\fR is at least 64 bytes in length.
87 .sp
88 .LP
89 For \fBputpmsg()\fR, the flags are different.  The \fIflags\fR argument is a
90 bitmask with the following mutually-exclusive flags defined: \fBMSG_HIPRI\fR
91 and \fBMSG_BAND\fR. If \fIflags\fR is set to 0, \fBputpmsg()\fR fails and sets
92 \fBerrno\fR to \fBEINVAL\fR. If a control part is specified and \fIflags\fR is
93 set to \fBMSG_HIPRI\fR and \fIband\fR is set to 0, a high-priority message is
94 sent. If \fIflags\fR is set to \fBMSG_HIPRI\fR and either no control part is
95 specified or \fIband\fR is set to a non-zero value, \fBputpmsg()\fR fails and
96 sets \fBerrno\fR to \fBEINVAL\fR. If flags is set to \fBMSG_BAND\fR, then a
97 message is sent in the priority band specified by \fIband\fR. If a control part
98 and data part are not specified and \fIflags\fR is set to \fBMSG_BAND\fR, no
99 message is sent and 0 is returned.
102 Normally, \fBputmsg()\fR will block if the stream write queue is full  due to
103 internal flow control conditions. For high-priority messages,  \fBputmsg()\fR
104 does not block on this condition. For other messages,  \fBputmsg()\fR does not
105 block when the write queue is full and  \fBO_NDELAY\fR or \fBO_NONBLOCK\fR is
106 set. Instead, it fails and sets  \fBerrno\fR to \fBEAGAIN\fR.
109 The \fBputmsg()\fR or \fBputpmsg()\fR function also blocks, unless prevented by
110 lack of internal resources, waiting  for the availability of message blocks in
111 the stream, regardless of priority  or whether \fBO_NDELAY\fR or
112 \fBO_NONBLOCK\fR has been specified. No partial message is sent.
113 .SH RETURN VALUES
116 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
117 returned and \fBerrno\fR is set to indicate the error.
118 .SH ERRORS
121 The \fBputmsg()\fR and \fBputpmsg()\fR functions will fail if:
123 .ne 2
125 \fB\fBEAGAIN\fR\fR
127 .RS 16n
128 A non-priority message was specified, the \fBO_NDELAY\fR or \fBO_NONBLOCK\fR
129 flag is  set and the stream write queue is full due to internal flow control
130 conditions.
134 .ne 2
136 \fB\fBEBADF\fR\fR
138 .RS 16n
139 The \fIfildes\fR argument is not a valid file descriptor open for writing.
143 .ne 2
145 \fB\fBEFAULT\fR\fR
147 .RS 16n
148 The \fIctlptr\fR or \fIdataptr\fR argument points to an illegal address.
152 .ne 2
154 \fB\fBEINTR\fR\fR
156 .RS 16n
157 A signal was caught during the execution of the \fBputmsg()\fR function.
161 .ne 2
163 \fB\fBEINVAL\fR\fR
165 .RS 16n
166 An undefined value was specified in \fIflags\fR; \fIflags\fR is set to
167 \fBRS_HIPRI\fR and no control part was supplied; or the stream referenced by
168 \fIfildes\fR is linked below a multiplexor.
172 .ne 2
174 \fB\fBENOSR\fR\fR
176 .RS 16n
177 Buffers could not be allocated for the message that was to be created due to
178 insufficient streams memory resources.
182 .ne 2
184 \fB\fBENOSTR\fR\fR
186 .RS 16n
187 The \fIfildes\fR argument is not associated with a stream.
191 .ne 2
193 \fB\fBENXIO\fR\fR
195 .RS 16n
196 A hangup condition was generated downstream for the specified stream, or the
197 other end of the pipe is closed.
201 .ne 2
203 \fB\fBEPIPE\fR or \fBEIO\fR\fR
205 .RS 16n
206 The \fIfildes\fR argument refers to a streams-based pipe and the other end of
207 the pipe is closed.  A \fBSIGPIPE\fR signal is generated for the calling
208 thread. This error condition occurs only with SUS-conforming applications. See
209 \fBstandards\fR(5).
213 .ne 2
215 \fB\fBERANGE\fR\fR
217 .RS 16n
218 The size of the data part of the message does not fall within the range
219 specified by the maximum and minimum packet sizes of the topmost stream module.
220 This value is also returned if the control part of the message is larger than
221 the maximum configured size of the control part of a message, or if the data
222 part of a message is larger than the maximum configured size of the data part
223 of a message.
228 In addition, \fBputmsg()\fR and \fBputpmsg()\fR will fail if the stream head
229 had processed an asynchronous error before the call.  In this case, the value
230 of \fBerrno\fR does not reflect the result of \fBputmsg()\fR or \fBputpmsg()\fR
231 but reflects the prior error.
234 The \fBputpmsg()\fR function will fail if:
236 .ne 2
238 \fB\fBEINVAL\fR\fR
240 .RS 10n
241 The \fIflags\fR argument is set to \fBMSG_HIPRI\fR and \fIband\fR is non-zero.
244 .SH ATTRIBUTES
247 See \fBattributes\fR(5) for descriptions of the following attributes:
252 box;
253 c | c
254 l | l .
255 ATTRIBUTE TYPE  ATTRIBUTE VALUE
257 Interface Stability     Standard
260 .SH SEE ALSO
263 \fBIntro\fR(2), \fBgetmsg\fR(2), \fBpoll\fR(2), \fBread\fR(2), \fBwrite\fR(2),
264 \fBattributes\fR(5), \fBstandards\fR(5)
267 \fISTREAMS Programming Guide\fR