summaryrefslogtreecommitdiff
path: root/static/unix-v10/man4/stream.4
blob: 24fd2c06d433e6ed40c2c1d5ae84e2bf36965b94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
.TH STREAM 4
.CT 2 comm_proc
.SH NAME
stream \- I/O control for streams
.SH SYNOPSIS
.B #include <sys/filio.h>
.br
.B #include <sys/ttyio.h>
.PP
.B ioctl(fd, code, param)
.br
.B void *param;
.SH DESCRIPTION
A stream is a connection between two processes, or between a process
and a device.
It is referred to by a file descriptor, and ordinary read and write
calls apply.
When a
.IR write (2)
call is given on a stream whose other end has disappeared,
for example because the process at other end of a pipe has terminated,
or a device has hung up, signal 
.B SIGPIPE
is generated; if the signal is ignored,
the write call returns error
.BR EPIPE .
The first several (currently 64)
.IR read (2)
calls on such a disconnected streams
return 0;
subsequent calls generate
.B SIGPIPE
signals.
.PP
Processing modules may be inserted into streams.
These
.IR ioctl (2)
calls insert, delete, inspect, and perform operations for stream
I/O modules.
They apply to the file descriptor of any open stream object:
terminal, network connection, pipe.
The
.I param
argument is a general pointer which, for these calls, is often
null, a pointer to
.BR int .
The codes are
.TF FIOPUSHLD
.TP
.B FIOPUSHLD
Insert, at the near end of the stream, the line discipline named by
the integer to which
.I param
points.
A census of line discipline modules is given below.
.PD
.TP
.B FIOINSLD
Insert a named line discipline at a given level in a stack
of such modules on the stream.
.I Param
points to a structure containing two short integers
respectively naming the line discipline and the level.
A level of 0 could be accomplished by
.BR FIOPUSHLD .
.TP
.B FIOPOPLD
Pop (removes) the nearest line discipline module, if
.I param
is 0 (null).
If
.I param
points to an integer, the line discipline at that level is removed.
The integer 0 is the same as a null
.IR param .
.TP
.B FIOLOOKLD
Return the number of the topmost line discipline in the stack.
If
.I param
is not 0 but instead points to an integer, the line discipline at that
level is returned in the same integer.
.TP
.B FIOSNDFD
Send the integer file descriptor pointed to by
.IR param
to the process on the other end of pipe
.IR fd .
The code is transmitted directly to the other end of
the pipe, untransformed by line disciplines.
It cannot be forged by the message line discipline,
.IR mesgld (4).
The call returns immediately; it does not rendezvous with
the matching
.BR FIORCVFD .
.TP
.B FIORCVFD
Deliver a structure pointed to by
.IR param :
.EX
struct passfd {
	int	fd;
	short	uid;
	short	gid;
	short	nice;
	char	logname[8];
	char	cap;
};
.EE
.IP
The call blocks until there is something in the stream.
If data is present, it returns
.BR EIO .
If a file descriptor has been sent from the other
end of the pipe by
.BR FIOSNDFD ,
.B FIORCVFD
fills in the user and group ID of the sending process,
its niceness (see
.IR nice (2)),
its login name, its capabilities in the form of the field
.B lb_t
(see
.IR getflab (2)),
and a file descriptor for the file
being sent; the file is now open in the receiving process.
Another use of
.B FIORCVFD
is described in
.IR connld (4).
.TP
.B FIONREAD
Store, in the integer pointed to by
.IR param ,
the number of characters that may be read from this stream
without possible blocking.
.TP
.B FIOGSRC
Copy the stream identifier to the
.BR SSRCSIZ -byte
string pointed to by
.IR param.
.TP
.B FIOSSRC
Copy the
.BR SSRCSIZ -byte
string pointed to by
.I param
into the stream identifier.
Capability
.B T_EXTERN
is required; see
.IR getplab (2).
Empty by default, the stream identifier is customarily
set on network connections to identify the source.
Successful password demands may also be recorded
in the stream identifier for the benefit of
.IR pwserv (8);
see
.IR session (1).
.TP
.B TIOCSPGRP
Make this process the head of a process group and makes this stream
its control stream.
When signals, such as hangup, interrupt, and quit, arrive at
a control stream, they are sent to its process group.
Child processes inherit the process group of their parent.
Process groups are created only by explicit use of this call,
and not implicitly by opening certain devices.
.I Param
must be 0.
.TP
.B TIOCGPGRP
Store through
.I param
a
.B short
naming the process group associated with the stream.
.TP
.B TIOCEXCL
Mark this stream as inaccessible except by the super-user
or by processes in the group associated with this stream.
.TP
.B TIOCNXCL
Remove the inaccessibility of the stream.
.TP
.B TIOCSBRK
Generate a message requesting
a line break.
The message is understood by devices capable of generating it
(such as asynchronous character devices) and ignored otherwise.
.TP
.B TIOCFLUSH
Generate a message causing downstream modules to throw away any
queued characters, if possible.
It applies to both input and output queues.
If the stream serves a device, the flush message may
cause further action in the device driver.
.TP
.B TIOCXFLUSH
Delete all data and messages from input and output queues.
No flush message is passed down the stream or to a
device driver.
.LP
Here is a list of available line discipline modules.
Each is an external integer, defined in 
.IR libc ;
see
.IR intro (3).
.TF rmesg_ld
.TP
.B tty_ld
Regular terminal processing; see
.IR ttyld (4).
.TP
.B ntty_ld
Terminal processing according to (modified) Berkeley `new tty' rules;
see Berkeley Users Manual.
.TP
.B cdkp_ld
Character-mode Datakit universal receiver protocol.
.TP
.B dkp_ld
Block-mode Datakit universal receiver protocol.
.TP
.B rdk_ld
.TP
.B uxp_ld
Special Datakit protocols used in connection setup.
.TP
.B buf_ld
Buffering mechanism;
see
.IR bufld (4).
.TP
.B mesg_ld
turns stream control blocks arriving in the read direction into
data messages, and written messages into controls.
See
.IR mesgld (4).
.TP 
.B rmesg_ld
inverse of
.BR mesg_ld .
.TP
.B conn_ld
For making unique connections to servers.
See
.IR connld (4).
.TP
.B ip_ld
.TP
.B tcp_ld
.TP
.B udp_ld
.TP
.B arp_ld
Internet protocols;
see
.IR internet (3).
.SH SEE ALSO
.IR ioctl (2),
.IR getstsrc (3)
.br
D. M. Ritchie,
`A Stream I/O System'
.I BLTJ,
October, 1984
.br
.I
UNIX Programmer's Manual, Seventh Edition, Virtual VAX-11 Version,
1980 (Berkeley)