]>
Commit | Line | Data |
---|---|---|
390f1f34 | 1 | .\" Copyright (c) 1993 Michael Haardt (michael@moria.de) |
fea681da | 2 | .\" Fri Apr 2 11:32:09 MET DST 1993 |
390f1f34 | 3 | .\" Copyright (c) 2006-2015, Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 4 | .\" |
e4a74ca8 | 5 | .\" SPDX-License-Identifier: GPL-2.0-or-later |
fea681da MK |
6 | .\" |
7 | .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu> | |
8 | .\" Modified 1995-02-25 by Jim Van Zandt <jrv@vanzandt.mv.com> | |
9 | .\" Modified 1995-09-02 by Jim Van Zandt <jrv@vanzandt.mv.com> | |
10 | .\" moved to man3, aeb, 950919 | |
c11b1abf | 11 | .\" Modified 2001-09-22 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da MK |
12 | .\" Modified 2001-12-17, aeb |
13 | .\" Modified 2004-10-31, aeb | |
19ab0376 MK |
14 | .\" 2006-12-28, mtk: |
15 | .\" Added .SS headers to give some structure to this page; and a | |
16 | .\" small amount of reordering. | |
a6712802 | 17 | .\" Added a section on canonical and noncanonical mode. |
19ab0376 MK |
18 | .\" Enhanced the discussion of "raw" mode for cfmakeraw(). |
19 | .\" Document CMSPAR. | |
fea681da | 20 | .\" |
4c1c5274 | 21 | .TH termios 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
22 | .SH NAME |
23 | termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, | |
24 | cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfsetspeed \- | |
25 | get and set terminal attributes, line control, get and set baud rate | |
968463ab AC |
26 | .SH LIBRARY |
27 | Standard C library | |
8fc3b2cf | 28 | .RI ( libc ", " \-lc ) |
fea681da | 29 | .SH SYNOPSIS |
04bb6cc0 | 30 | .nf |
c91e381d | 31 | .B #include <termios.h> |
c91e381d | 32 | .B #include <unistd.h> |
68e4db0a | 33 | .PP |
fea681da | 34 | .BI "int tcgetattr(int " fd ", struct termios *" termios_p ); |
04bb6cc0 MK |
35 | .BI "int tcsetattr(int " fd ", int " optional_actions , |
36 | .BI " const struct termios *" termios_p ); | |
68e4db0a | 37 | .PP |
fea681da | 38 | .BI "int tcsendbreak(int " fd ", int " duration ); |
fea681da | 39 | .BI "int tcdrain(int " fd ); |
fea681da | 40 | .BI "int tcflush(int " fd ", int " queue_selector ); |
fea681da | 41 | .BI "int tcflow(int " fd ", int " action ); |
68e4db0a | 42 | .PP |
fea681da | 43 | .BI "void cfmakeraw(struct termios *" termios_p ); |
68e4db0a | 44 | .PP |
fea681da | 45 | .BI "speed_t cfgetispeed(const struct termios *" termios_p ); |
fea681da | 46 | .BI "speed_t cfgetospeed(const struct termios *" termios_p ); |
68e4db0a | 47 | .PP |
fea681da | 48 | .BI "int cfsetispeed(struct termios *" termios_p ", speed_t " speed ); |
fea681da | 49 | .BI "int cfsetospeed(struct termios *" termios_p ", speed_t " speed ); |
52dab97a | 50 | .BI "int cfsetspeed(struct termios *" termios_p ", speed_t " speed ); |
04bb6cc0 | 51 | .fi |
68e4db0a | 52 | .PP |
d39ad78f | 53 | .RS -4 |
cc4615cc MK |
54 | Feature Test Macro Requirements for glibc (see |
55 | .BR feature_test_macros (7)): | |
d39ad78f | 56 | .RE |
68e4db0a | 57 | .PP |
cc4615cc MK |
58 | .BR cfsetspeed (), |
59 | .BR cfmakeraw (): | |
9d281e06 | 60 | .nf |
51c612fb MK |
61 | Since glibc 2.19: |
62 | _DEFAULT_SOURCE | |
63 | Glibc 2.19 and earlier: | |
64 | _BSD_SOURCE | |
9d281e06 | 65 | .fi |
fea681da MK |
66 | .SH DESCRIPTION |
67 | The termios functions describe a general terminal interface that is | |
68 | provided to control asynchronous communications ports. | |
73d8cece | 69 | .SS The termios structure |
fea681da | 70 | Many of the functions described here have a \fItermios_p\fP argument |
c13182ef MK |
71 | that is a pointer to a \fItermios\fP structure. |
72 | This structure contains at least the following members: | |
51f5698d | 73 | .PP |
a6e2f128 | 74 | .in +4n |
bdd915e2 | 75 | .EX |
bd9b2a9c MK |
76 | tcflag_t c_iflag; /* input modes */ |
77 | tcflag_t c_oflag; /* output modes */ | |
78 | tcflag_t c_cflag; /* control modes */ | |
79 | tcflag_t c_lflag; /* local modes */ | |
d8b24e6e | 80 | cc_t c_cc[NCCS]; /* special characters */ |
bdd915e2 | 81 | .EE |
a6e2f128 | 82 | .in |
fea681da | 83 | .PP |
869ebe5b | 84 | The values that may be assigned to these fields are described below. |
c13182ef MK |
85 | In the case of the first four bit-mask fields, |
86 | the definitions of some of the associated flags that may be set are | |
33a0ccb2 | 87 | exposed only if a specific feature test macro (see |
a8e7c990 | 88 | .BR feature_test_macros (7)) |
869ebe5b MK |
89 | is defined, as noted in brackets ("[]"). |
90 | .PP | |
42b09930 | 91 | In the descriptions below, "not in POSIX" means that the |
c13182ef MK |
92 | value is not specified in POSIX.1-2001, |
93 | and "XSI" means that the value is specified in POSIX.1-2001 | |
42b09930 MK |
94 | as part of the XSI extension. |
95 | .PP | |
fea681da MK |
96 | \fIc_iflag\fP flag constants: |
97 | .TP | |
98 | .B IGNBRK | |
99 | Ignore BREAK condition on input. | |
100 | .TP | |
101 | .B BRKINT | |
c13182ef MK |
102 | If \fBIGNBRK\fP is set, a BREAK is ignored. |
103 | If it is not set | |
fea681da MK |
104 | but \fBBRKINT\fP is set, then a BREAK causes the input and output |
105 | queues to be flushed, and if the terminal is the controlling | |
106 | terminal of a foreground process group, it will cause a | |
107 | \fBSIGINT\fP to be sent to this foreground process group. | |
108 | When neither \fBIGNBRK\fP nor \fBBRKINT\fP are set, a BREAK | |
d1a71985 MK |
109 | reads as a null byte (\(aq\e0\(aq), except when \fBPARMRK\fP is set, |
110 | in which case it reads as the sequence \e377 \e0 \e0. | |
fea681da MK |
111 | .TP |
112 | .B IGNPAR | |
113 | Ignore framing errors and parity errors. | |
114 | .TP | |
115 | .B PARMRK | |
2d7c8f1f | 116 | If this bit is set, input bytes with parity or framing errors are |
a0262e27 MK |
117 | marked when passed to the program. |
118 | This bit is meaningful only when | |
2d7c8f1f OT |
119 | \fBINPCK\fP is set and \fBIGNPAR\fP is not set. |
120 | The way erroneous bytes are marked is with two preceding bytes, | |
d1a71985 | 121 | \e377 and \e0. |
a0262e27 | 122 | Thus, the program actually reads three bytes for one |
2d7c8f1f | 123 | erroneous byte received from the terminal. |
d1a71985 | 124 | If a valid byte has the value \e377, |
a0262e27 MK |
125 | and \fBISTRIP\fP (see below) is not set, |
126 | the program might confuse it with the prefix that marks a | |
127 | parity error. | |
d1a71985 MK |
128 | Therefore, a valid byte \e377 is passed to the program as two |
129 | bytes, \e377 \e377, in this case. | |
847e0d88 | 130 | .IP |
c13182ef | 131 | If neither \fBIGNPAR\fP nor \fBPARMRK\fP |
fea681da | 132 | is set, read a character with a parity error or framing error |
d1a71985 | 133 | as \e0. |
fea681da MK |
134 | .TP |
135 | .B INPCK | |
136 | Enable input parity checking. | |
137 | .TP | |
138 | .B ISTRIP | |
139 | Strip off eighth bit. | |
140 | .TP | |
141 | .B INLCR | |
142 | Translate NL to CR on input. | |
143 | .TP | |
144 | .B IGNCR | |
145 | Ignore carriage return on input. | |
146 | .TP | |
147 | .B ICRNL | |
148 | Translate carriage return to newline on input (unless \fBIGNCR\fP is set). | |
149 | .TP | |
150 | .B IUCLC | |
151 | (not in POSIX) Map uppercase characters to lowercase on input. | |
152 | .TP | |
153 | .B IXON | |
154 | Enable XON/XOFF flow control on output. | |
155 | .TP | |
156 | .B IXANY | |
c13182ef | 157 | (XSI) Typing any character will restart stopped output. |
42b09930 | 158 | (The default is to allow just the START character to restart output.) |
fea681da MK |
159 | .TP |
160 | .B IXOFF | |
161 | Enable XON/XOFF flow control on input. | |
162 | .TP | |
163 | .B IMAXBEL | |
164 | (not in POSIX) Ring bell when input queue is full. | |
165 | Linux does not implement this bit, and acts as if it is always set. | |
225c76e9 MK |
166 | .TP |
167 | .BR IUTF8 " (since Linux 2.6.4)" | |
c13182ef | 168 | (not in POSIX) Input is UTF8; |
225c76e9 | 169 | this allows character-erase to be correctly performed in cooked mode. |
fea681da | 170 | .PP |
73da3537 MK |
171 | .I c_oflag |
172 | flag constants: | |
fea681da MK |
173 | .TP |
174 | .B OPOST | |
175 | Enable implementation-defined output processing. | |
fea681da MK |
176 | .TP |
177 | .B OLCUC | |
178 | (not in POSIX) Map lowercase characters to uppercase on output. | |
179 | .TP | |
180 | .B ONLCR | |
181 | (XSI) Map NL to CR-NL on output. | |
182 | .TP | |
183 | .B OCRNL | |
184 | Map CR to NL on output. | |
185 | .TP | |
186 | .B ONOCR | |
187 | Don't output CR at column 0. | |
188 | .TP | |
189 | .B ONLRET | |
958604aa SB |
190 | The NL character is assumed to do the carriage-return function; |
191 | the kernel's idea of the current column is set to 0 | |
192 | after both NL and CR. | |
fea681da MK |
193 | .TP |
194 | .B OFILL | |
195 | Send fill characters for a delay, rather than using a timed delay. | |
196 | .TP | |
197 | .B OFDEL | |
ffcffad6 | 198 | Fill character is ASCII DEL (0177). |
d1a71985 | 199 | If unset, fill character is ASCII NUL (\(aq\e0\(aq). |
42b09930 | 200 | (Not implemented on Linux.) |
fea681da MK |
201 | .TP |
202 | .B NLDLY | |
c13182ef MK |
203 | Newline delay mask. |
204 | Values are \fBNL0\fP and \fBNL1\fP. | |
db4e96b7 MK |
205 | [requires |
206 | .B _BSD_SOURCE | |
207 | or | |
208 | .B _SVID_SOURCE | |
c90511a6 MK |
209 | or |
210 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
211 | .TP |
212 | .B CRDLY | |
213 | Carriage return delay mask. | |
214 | Values are \fBCR0\fP, \fBCR1\fP, \fBCR2\fP, or \fBCR3\fP. | |
db4e96b7 MK |
215 | [requires |
216 | .B _BSD_SOURCE | |
217 | or | |
218 | .B _SVID_SOURCE | |
c90511a6 MK |
219 | or |
220 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
221 | .TP |
222 | .B TABDLY | |
223 | Horizontal tab delay mask. | |
499eb81f ES |
224 | Values are \fBTAB0\fP, \fBTAB1\fP, \fBTAB2\fP, \fBTAB3\fP (or \fBXTABS\fP, |
225 | but see the | |
226 | .B BUGS | |
227 | section). | |
fea681da MK |
228 | A value of TAB3, that is, XTABS, expands tabs to spaces |
229 | (with tab stops every eight columns). | |
db4e96b7 MK |
230 | [requires |
231 | .B _BSD_SOURCE | |
232 | or | |
233 | .B _SVID_SOURCE | |
c90511a6 MK |
234 | or |
235 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
236 | .TP |
237 | .B BSDLY | |
c13182ef MK |
238 | Backspace delay mask. |
239 | Values are \fBBS0\fP or \fBBS1\fP. | |
fea681da | 240 | (Has never been implemented.) |
db4e96b7 MK |
241 | [requires |
242 | .B _BSD_SOURCE | |
243 | or | |
244 | .B _SVID_SOURCE | |
c90511a6 MK |
245 | or |
246 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
247 | .TP |
248 | .B VTDLY | |
c13182ef MK |
249 | Vertical tab delay mask. |
250 | Values are \fBVT0\fP or \fBVT1\fP. | |
fea681da MK |
251 | .TP |
252 | .B FFDLY | |
c13182ef MK |
253 | Form feed delay mask. |
254 | Values are \fBFF0\fP or \fBFF1\fP. | |
db4e96b7 MK |
255 | [requires |
256 | .B _BSD_SOURCE | |
257 | or | |
258 | .B _SVID_SOURCE | |
c90511a6 MK |
259 | or |
260 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
261 | .PP |
262 | \fIc_cflag\fP flag constants: | |
263 | .TP | |
264 | .B CBAUD | |
265 | (not in POSIX) Baud speed mask (4+1 bits). | |
db4e96b7 MK |
266 | [requires |
267 | .B _BSD_SOURCE | |
c90511a6 MK |
268 | or |
269 | .BR _SVID_SOURCE ] | |
fea681da MK |
270 | .TP |
271 | .B CBAUDEX | |
097585ed MK |
272 | (not in POSIX) Extra baud speed mask (1 bit), included in |
273 | .BR CBAUD . | |
db4e96b7 MK |
274 | [requires |
275 | .B _BSD_SOURCE | |
c90511a6 MK |
276 | or |
277 | .BR _SVID_SOURCE ] | |
bdd915e2 | 278 | .IP |
c13182ef MK |
279 | (POSIX says that the baud speed is stored in the |
280 | .I termios | |
42b09930 | 281 | structure without specifying where precisely, and provides |
63aa9df0 | 282 | .BR cfgetispeed () |
fea681da | 283 | and |
63aa9df0 | 284 | .BR cfsetispeed () |
c13182ef | 285 | for getting at it. |
097585ed MK |
286 | Some systems use bits selected by |
287 | .B CBAUD | |
288 | in | |
fea681da | 289 | .IR c_cflag , |
75b94dc3 | 290 | other systems use separate fields, for example, |
fea681da MK |
291 | .I sg_ispeed |
292 | and | |
293 | .IR sg_ospeed .) | |
294 | .TP | |
295 | .B CSIZE | |
296 | Character size mask. | |
297 | Values are \fBCS5\fP, \fBCS6\fP, \fBCS7\fP, or \fBCS8\fP. | |
298 | .TP | |
299 | .B CSTOPB | |
300 | Set two stop bits, rather than one. | |
301 | .TP | |
302 | .B CREAD | |
303 | Enable receiver. | |
304 | .TP | |
305 | .B PARENB | |
306 | Enable parity generation on output and parity checking for input. | |
307 | .TP | |
308 | .B PARODD | |
c13182ef | 309 | If set, then parity for input and output is odd; |
19ab0376 | 310 | otherwise even parity is used. |
fea681da MK |
311 | .TP |
312 | .B HUPCL | |
313 | Lower modem control lines after last process closes the device (hang up). | |
314 | .TP | |
315 | .B CLOCAL | |
316 | Ignore modem control lines. | |
317 | .TP | |
318 | .B LOBLK | |
24b74457 | 319 | (not in POSIX) Block output from a noncurrent shell layer. |
5e833e27 MK |
320 | For use by \fBshl\fP (shell layers). |
321 | (Not implemented on Linux.) | |
fea681da MK |
322 | .TP |
323 | .B CIBAUD | |
4a837837 | 324 | (not in POSIX) Mask for input speeds. |
097585ed MK |
325 | The values for the |
326 | .B CIBAUD | |
327 | bits are | |
328 | the same as the values for the | |
329 | .B CBAUD | |
330 | bits, shifted left | |
331 | .B IBSHIFT | |
332 | bits. | |
db4e96b7 MK |
333 | [requires |
334 | .B _BSD_SOURCE | |
c90511a6 MK |
335 | or |
336 | .BR _SVID_SOURCE ] | |
0338d6aa PR |
337 | (Not implemented in glibc, supported on Linux via |
338 | .BR TCGET * | |
339 | and | |
340 | .BR TCSET * | |
341 | ioctls; see | |
342 | .BR ioctl_tty (2)) | |
fea681da | 343 | .TP |
adab6032 | 344 | .B CMSPAR |
ad715af9 | 345 | (not in POSIX) |
c13182ef | 346 | Use "stick" (mark/space) parity (supported on certain serial |
4a837837 | 347 | devices): if |
c13182ef | 348 | .B PARODD |
adab6032 | 349 | is set, the parity bit is always 1; if |
c13182ef | 350 | .B PARODD |
69ef1f65 | 351 | is not set, then the parity bit is always 0. |
db4e96b7 MK |
352 | [requires |
353 | .B _BSD_SOURCE | |
c90511a6 MK |
354 | or |
355 | .BR _SVID_SOURCE ] | |
adab6032 | 356 | .TP |
fea681da MK |
357 | .B CRTSCTS |
358 | (not in POSIX) Enable RTS/CTS (hardware) flow control. | |
db4e96b7 MK |
359 | [requires |
360 | .B _BSD_SOURCE | |
c90511a6 MK |
361 | or |
362 | .BR _SVID_SOURCE ] | |
fea681da MK |
363 | .PP |
364 | \fIc_lflag\fP flag constants: | |
365 | .TP | |
366 | .B ISIG | |
367 | When any of the characters INTR, QUIT, SUSP, or DSUSP are received, | |
368 | generate the corresponding signal. | |
369 | .TP | |
370 | .B ICANON | |
c13182ef | 371 | Enable canonical mode (described below). |
fea681da MK |
372 | .TP |
373 | .B XCASE | |
374 | (not in POSIX; not supported under Linux) | |
375 | If \fBICANON\fP is also set, terminal is uppercase only. | |
d1a71985 MK |
376 | Input is converted to lowercase, except for characters preceded by \e. |
377 | On output, uppercase characters are preceded by \e and lowercase | |
fea681da | 378 | characters are converted to uppercase. |
6d1f5ca5 YK |
379 | [requires |
380 | .B _BSD_SOURCE | |
381 | or | |
382 | .B _SVID_SOURCE | |
383 | or | |
384 | .BR _XOPEN_SOURCE ] | |
c3dfd2c8 | 385 | .\" glibc is probably now wrong to allow |
eee28e75 MK |
386 | .\" Define |
387 | .\" .B _XOPEN_SOURCE | |
388 | .\" to expose | |
389 | .\" .BR XCASE . | |
fea681da MK |
390 | .TP |
391 | .B ECHO | |
392 | Echo input characters. | |
393 | .TP | |
394 | .B ECHOE | |
395 | If \fBICANON\fP is also set, the ERASE character erases the preceding | |
396 | input character, and WERASE erases the preceding word. | |
397 | .TP | |
398 | .B ECHOK | |
399 | If \fBICANON\fP is also set, the KILL character erases the current line. | |
400 | .TP | |
401 | .B ECHONL | |
402 | If \fBICANON\fP is also set, echo the NL character even if ECHO is not set. | |
403 | .TP | |
404 | .B ECHOCTL | |
d8b24e6e MK |
405 | (not in POSIX) If \fBECHO\fP is also set, |
406 | terminal special characters other than | |
9ca13180 | 407 | TAB, NL, START, and STOP are echoed as \fB\(haX\fP, |
8bb93cd4 | 408 | where X is the character with |
d8b24e6e | 409 | ASCII code 0x40 greater than the special character. |
c13182ef | 410 | For example, character |
9ca13180 | 411 | 0x08 (BS) is echoed as \fB\(haH\fP. |
db4e96b7 MK |
412 | [requires |
413 | .B _BSD_SOURCE | |
c90511a6 MK |
414 | or |
415 | .BR _SVID_SOURCE ] | |
fea681da MK |
416 | .TP |
417 | .B ECHOPRT | |
96da8065 | 418 | (not in POSIX) If \fBICANON\fP and \fBECHO\fP are also set, characters |
fea681da | 419 | are printed as they are being erased. |
db4e96b7 MK |
420 | [requires |
421 | .B _BSD_SOURCE | |
c90511a6 MK |
422 | or |
423 | .BR _SVID_SOURCE ] | |
fea681da MK |
424 | .TP |
425 | .B ECHOKE | |
426 | (not in POSIX) If \fBICANON\fP is also set, KILL is echoed by erasing | |
427 | each character on the line, as specified by \fBECHOE\fP and \fBECHOPRT\fP. | |
db4e96b7 MK |
428 | [requires |
429 | .B _BSD_SOURCE | |
c90511a6 MK |
430 | or |
431 | .BR _SVID_SOURCE ] | |
fea681da MK |
432 | .TP |
433 | .B DEFECHO | |
434 | (not in POSIX) Echo only when a process is reading. | |
42b09930 | 435 | (Not implemented on Linux.) |
fea681da MK |
436 | .TP |
437 | .B FLUSHO | |
438 | (not in POSIX; not supported under Linux) | |
c13182ef MK |
439 | Output is being flushed. |
440 | This flag is toggled by typing | |
fea681da | 441 | the DISCARD character. |
db4e96b7 MK |
442 | [requires |
443 | .B _BSD_SOURCE | |
c90511a6 MK |
444 | or |
445 | .BR _SVID_SOURCE ] | |
fea681da MK |
446 | .TP |
447 | .B NOFLSH | |
6e502d47 MK |
448 | Disable flushing the input and output queues when generating signals for the |
449 | INT, QUIT, and SUSP characters. | |
450 | .\" Stevens lets SUSP only flush the input queue | |
fea681da MK |
451 | .TP |
452 | .B TOSTOP | |
8bd58774 MK |
453 | Send the |
454 | .B SIGTTOU | |
455 | signal to the process group of a background process | |
fea681da MK |
456 | which tries to write to its controlling terminal. |
457 | .TP | |
458 | .B PENDIN | |
459 | (not in POSIX; not supported under Linux) | |
460 | All characters in the input queue are reprinted when | |
c13182ef | 461 | the next character is read. |
5852aba2 MK |
462 | .RB ( bash (1) |
463 | handles typeahead this way.) | |
db4e96b7 MK |
464 | [requires |
465 | .B _BSD_SOURCE | |
c90511a6 MK |
466 | or |
467 | .BR _SVID_SOURCE ] | |
fea681da MK |
468 | .TP |
469 | .B IEXTEN | |
470 | Enable implementation-defined input processing. | |
0425de01 | 471 | This flag, as well as \fBICANON\fP must be enabled for the |
fea681da MK |
472 | special characters EOL2, LNEXT, REPRINT, WERASE to be interpreted, |
473 | and for the \fBIUCLC\fP flag to be effective. | |
474 | .PP | |
d8b24e6e | 475 | The \fIc_cc\fP array defines the terminal special characters. |
fea681da MK |
476 | The symbolic indices (initial values) and meaning are: |
477 | .TP | |
91e2779f MK |
478 | .B VDISCARD |
479 | (not in POSIX; not supported under Linux; 017, SI, Ctrl-O) | |
480 | Toggle: start/stop discarding pending output. | |
097585ed | 481 | Recognized when |
91e2779f | 482 | .B IEXTEN |
097585ed | 483 | is set, and then not passed as input. |
fea681da | 484 | .TP |
91e2779f MK |
485 | .B VDSUSP |
486 | (not in POSIX; not supported under Linux; 031, EM, Ctrl-Y) | |
489e425d | 487 | Delayed suspend character (DSUSP): |
91e2779f MK |
488 | send |
489 | .B SIGTSTP | |
490 | signal when the character is read by the user program. | |
097585ed | 491 | Recognized when |
91e2779f MK |
492 | .B IEXTEN |
493 | and | |
097585ed | 494 | .B ISIG |
91e2779f MK |
495 | are set, and the system supports |
496 | job control, and then not passed as input. | |
fea681da MK |
497 | .TP |
498 | .B VEOF | |
499 | (004, EOT, Ctrl-D) | |
489e425d | 500 | End-of-file character (EOF). |
fea681da MK |
501 | More precisely: this character causes the pending tty buffer to be sent |
502 | to the waiting user program without waiting for end-of-line. | |
d9c1ae64 MK |
503 | If it is the first character of the line, the |
504 | .BR read (2) | |
505 | in the user program returns 0, which signifies end-of-file. | |
097585ed MK |
506 | Recognized when |
507 | .B ICANON | |
508 | is set, and then not passed as input. | |
fea681da | 509 | .TP |
fea681da MK |
510 | .B VEOL |
511 | (0, NUL) | |
489e425d | 512 | Additional end-of-line character (EOL). |
097585ed MK |
513 | Recognized when |
514 | .B ICANON | |
515 | is set. | |
fea681da | 516 | .TP |
fea681da MK |
517 | .B VEOL2 |
518 | (not in POSIX; 0, NUL) | |
489e425d | 519 | Yet another end-of-line character (EOL2). |
097585ed MK |
520 | Recognized when |
521 | .B ICANON | |
522 | is set. | |
fea681da | 523 | .TP |
91e2779f MK |
524 | .B VERASE |
525 | (0177, DEL, rubout, or 010, BS, Ctrl-H, or also #) | |
489e425d | 526 | Erase character (ERASE). |
91e2779f MK |
527 | This erases the previous not-yet-erased character, |
528 | but does not erase past EOF or beginning-of-line. | |
097585ed | 529 | Recognized when |
91e2779f | 530 | .B ICANON |
097585ed | 531 | is set, and then not passed as input. |
fea681da | 532 | .TP |
91e2779f MK |
533 | .B VINTR |
534 | (003, ETX, Ctrl-C, or also 0177, DEL, rubout) | |
489e425d | 535 | Interrupt character (INTR). |
91e2779f MK |
536 | Send a |
537 | .B SIGINT | |
8bd58774 | 538 | signal. |
097585ed MK |
539 | Recognized when |
540 | .B ISIG | |
541 | is set, and then not passed as input. | |
fea681da | 542 | .TP |
91e2779f MK |
543 | .B VKILL |
544 | (025, NAK, Ctrl-U, or Ctrl-X, or also @) | |
489e425d | 545 | Kill character (KILL). |
91e2779f | 546 | This erases the input since the last EOF or beginning-of-line. |
097585ed | 547 | Recognized when |
91e2779f MK |
548 | .B ICANON |
549 | is set, and then not passed as input. | |
fea681da MK |
550 | .TP |
551 | .B VLNEXT | |
552 | (not in POSIX; 026, SYN, Ctrl-V) | |
489e425d | 553 | Literal next (LNEXT). |
c13182ef | 554 | Quotes the next input character, depriving it of |
fea681da | 555 | a possible special meaning. |
097585ed MK |
556 | Recognized when |
557 | .B IEXTEN | |
558 | is set, and then not passed as input. | |
fea681da | 559 | .TP |
91e2779f | 560 | .B VMIN |
489e425d | 561 | Minimum number of characters for noncanonical read (MIN). |
91e2779f MK |
562 | .TP |
563 | .B VQUIT | |
31a6818e | 564 | (034, FS, Ctrl-\e) |
489e425d | 565 | Quit character (QUIT). |
91e2779f MK |
566 | Send |
567 | .B SIGQUIT | |
568 | signal. | |
097585ed | 569 | Recognized when |
91e2779f MK |
570 | .B ISIG |
571 | is set, and then not passed as input. | |
fea681da MK |
572 | .TP |
573 | .B VREPRINT | |
574 | (not in POSIX; 022, DC2, Ctrl-R) | |
489e425d | 575 | Reprint unread characters (REPRINT). |
097585ed MK |
576 | Recognized when |
577 | .B ICANON | |
578 | and | |
579 | .B IEXTEN | |
580 | are set, and then not passed as input. | |
fea681da | 581 | .TP |
91e2779f MK |
582 | .B VSTART |
583 | (021, DC1, Ctrl-Q) | |
489e425d | 584 | Start character (START). |
91e2779f | 585 | Restarts output stopped by the Stop character. |
097585ed | 586 | Recognized when |
91e2779f | 587 | .B IXON |
097585ed | 588 | is set, and then not passed as input. |
fea681da MK |
589 | .TP |
590 | .B VSTATUS | |
591 | (not in POSIX; not supported under Linux; | |
592 | status request: 024, DC4, Ctrl-T). | |
a6639d09 MK |
593 | Status character (STATUS). |
594 | Display status information at terminal, | |
595 | including state of foreground process and amount of CPU time it has consumed. | |
596 | Also sends a | |
d8a86e74 | 597 | .B SIGINFO |
a6639d09 | 598 | signal (not supported on Linux) to the foreground process group. |
91e2779f MK |
599 | .TP |
600 | .B VSTOP | |
601 | (023, DC3, Ctrl-S) | |
489e425d | 602 | Stop character (STOP). |
91e2779f MK |
603 | Stop output until Start character typed. |
604 | Recognized when | |
605 | .B IXON | |
606 | is set, and then not passed as input. | |
607 | .TP | |
608 | .B VSUSP | |
609 | (032, SUB, Ctrl-Z) | |
489e425d | 610 | Suspend character (SUSP). |
91e2779f MK |
611 | Send |
612 | .B SIGTSTP | |
613 | signal. | |
614 | Recognized when | |
615 | .B ISIG | |
616 | is set, and then not passed as input. | |
617 | .TP | |
618 | .B VSWTCH | |
619 | (not in POSIX; not supported under Linux; 0, NUL) | |
489e425d | 620 | Switch character (SWTCH). |
33b7fff5 MK |
621 | Used in System V to switch shells in |
622 | .IR "shell layers" , | |
5aaf78b7 | 623 | a predecessor to shell job control. |
91e2779f MK |
624 | .TP |
625 | .B VTIME | |
489e425d | 626 | Timeout in deciseconds for noncanonical read (TIME). |
91e2779f MK |
627 | .TP |
628 | .B VWERASE | |
629 | (not in POSIX; 027, ETB, Ctrl-W) | |
489e425d | 630 | Word erase (WERASE). |
91e2779f MK |
631 | Recognized when |
632 | .B ICANON | |
633 | and | |
634 | .B IEXTEN | |
635 | are set, and then not passed as input. | |
dd3568a1 | 636 | .PP |
d51529b8 MK |
637 | An individual terminal special character can be disabled by setting |
638 | the value of the corresponding | |
639 | .I c_cc | |
640 | element to | |
641 | .BR _POSIX_VDISABLE . | |
dd3568a1 | 642 | .PP |
d51529b8 | 643 | The above symbolic subscript values are all different, except that |
097585ed | 644 | .BR VTIME , |
0daa9e92 | 645 | .B VMIN |
097585ed | 646 | may have the same value as |
3cf81850 | 647 | .BR VEOL , |
097585ed MK |
648 | .BR VEOF , |
649 | respectively. | |
a6712802 | 650 | In noncanonical mode the special character meaning is replaced |
c13182ef | 651 | by the timeout meaning. |
097585ed MK |
652 | For an explanation of |
653 | .B VMIN | |
654 | and | |
655 | .BR VTIME , | |
656 | see the description of | |
a6712802 | 657 | noncanonical mode below. |
73d8cece | 658 | .SS Retrieving and changing terminal settings |
63aa9df0 | 659 | .BR tcgetattr () |
fea681da | 660 | gets the parameters associated with the object referred by \fIfd\fP and |
869ebe5b | 661 | stores them in the \fItermios\fP structure referenced by |
c13182ef MK |
662 | \fItermios_p\fP. |
663 | This function may be invoked from a background process; | |
fea681da MK |
664 | however, the terminal attributes may be subsequently changed by a |
665 | foreground process. | |
dd3568a1 | 666 | .PP |
63aa9df0 | 667 | .BR tcsetattr () |
fea681da MK |
668 | sets the parameters associated with the terminal (unless support is |
669 | required from the underlying hardware that is not available) from the | |
c13182ef | 670 | \fItermios\fP structure referred to by \fItermios_p\fP. |
fea681da | 671 | \fIoptional_actions\fP specifies when the changes take effect: |
4279e42d AC |
672 | .TP |
673 | .B TCSANOW | |
fea681da | 674 | the change occurs immediately. |
4279e42d AC |
675 | .TP |
676 | .B TCSADRAIN | |
fea681da MK |
677 | the change occurs after all output written to |
678 | .I fd | |
c13182ef | 679 | has been transmitted. |
d1c2e0f2 | 680 | This option should be used when changing |
fea681da | 681 | parameters that affect output. |
4279e42d AC |
682 | .TP |
683 | .B TCSAFLUSH | |
fea681da MK |
684 | the change occurs after all output written to the object referred by |
685 | .I fd | |
686 | has been transmitted, and all input that has been received but not read | |
687 | will be discarded before the change is made. | |
73d8cece | 688 | .SS Canonical and noncanonical mode |
19ab0376 MK |
689 | The setting of the |
690 | .B ICANON | |
691 | canon flag in | |
692 | .I c_lflag | |
693 | determines whether the terminal is operating in canonical mode | |
694 | .RB ( ICANON | |
695 | set) or | |
a6712802 | 696 | noncanonical mode |
c13182ef | 697 | .RB ( ICANON |
19ab0376 MK |
698 | unset). |
699 | By default, | |
700 | .B ICANON | |
8d48cea3 | 701 | is set. |
847e0d88 | 702 | .PP |
19ab0376 | 703 | In canonical mode: |
22356d97 | 704 | .IP \(bu 3 |
19ab0376 MK |
705 | Input is made available line by line. |
706 | An input line is available when one of the line delimiters | |
707 | is typed (NL, EOL, EOL2; or EOF at the start of line). | |
708 | Except in the case of EOF, the line delimiter is included | |
709 | in the buffer returned by | |
710 | .BR read (2). | |
22356d97 | 711 | .IP \(bu |
c13182ef MK |
712 | Line editing is enabled (ERASE, KILL; |
713 | and if the | |
19ab0376 MK |
714 | .B IEXTEN |
715 | flag is set: WERASE, REPRINT, LNEXT). | |
c13182ef | 716 | A |
fb186734 | 717 | .BR read (2) |
19ab0376 | 718 | returns at most one line of input; if the |
fb186734 | 719 | .BR read (2) |
19ab0376 MK |
720 | requested fewer bytes than are available in the current line of input, |
721 | then only as many bytes as requested are read, | |
722 | and the remaining characters will be available for a future | |
fb186734 | 723 | .BR read (2). |
22356d97 | 724 | .IP \(bu |
7a727dc4 MK |
725 | The maximum line length is 4096 chars |
726 | (including the terminating newline character); | |
727 | lines longer than 4096 chars are truncated. | |
988c4c42 MK |
728 | After 4095 characters, input processing (e.g., |
729 | .B ISIG | |
730 | and | |
731 | .B ECHO* | |
732 | processing) continues, but any input data after 4095 characters up to | |
733 | (but not including) any terminating newline is discarded. | |
7a727dc4 MK |
734 | This ensures that the terminal can always receive |
735 | more input until at least one line can be read. | |
19ab0376 | 736 | .PP |
a6712802 | 737 | In noncanonical mode input is available immediately (without |
19ab0376 | 738 | the user having to type a line-delimiter character), |
764d3de3 | 739 | no input processing is performed, |
19ab0376 | 740 | and line editing is disabled. |
5ad8a9d7 DTQ |
741 | The read buffer will only accept 4095 chars; this provides the |
742 | necessary space for a newline char if the input mode is switched | |
743 | to canonical. | |
c13182ef | 744 | The settings of MIN |
19ab0376 | 745 | .RI ( c_cc[VMIN] ) |
0f8b10eb | 746 | and TIME |
19ab0376 MK |
747 | .RI ( c_cc[VTIME] ) |
748 | determine the circumstances in which a | |
749 | .BR read (2) | |
750 | completes; there are four distinct cases: | |
959c4b25 | 751 | .TP |
f8f8b9c1 | 752 | MIN == 0, TIME == 0 (polling read) |
19ab0376 | 753 | If data is available, |
fb186734 | 754 | .BR read (2) |
19ab0376 MK |
755 | returns immediately, with the lesser of the number of bytes |
756 | available, or the number of bytes requested. | |
757 | If no data is available, | |
fb186734 | 758 | .BR read (2) |
19ab0376 | 759 | returns 0. |
959c4b25 | 760 | .TP |
f8f8b9c1 | 761 | MIN > 0, TIME == 0 (blocking read) |
fb186734 | 762 | .BR read (2) |
4b985dd6 MK |
763 | blocks until MIN bytes are available, |
764 | and returns up to the number of bytes requested. | |
959c4b25 | 765 | .TP |
f8f8b9c1 | 766 | MIN == 0, TIME > 0 (read with timeout) |
19ab0376 | 767 | TIME specifies the limit for a timer in tenths of a second. |
c13182ef | 768 | The timer is started when |
fb186734 | 769 | .BR read (2) |
19ab0376 | 770 | is called. |
fb186734 | 771 | .BR read (2) |
19ab0376 MK |
772 | returns either when at least one byte of data is available, |
773 | or when the timer expires. | |
774 | If the timer expires without any input becoming available, | |
fb186734 | 775 | .BR read (2) |
19ab0376 | 776 | returns 0. |
e764d1b7 | 777 | If data is already available at the time of the call to |
8563c249 | 778 | .BR read (2), |
e764d1b7 | 779 | the call behaves as though the data was received immediately after the call. |
959c4b25 | 780 | .TP |
f8f8b9c1 | 781 | MIN > 0, TIME > 0 (read with interbyte timeout) |
19ab0376 MK |
782 | TIME specifies the limit for a timer in tenths of a second. |
783 | Once an initial byte of input becomes available, | |
784 | the timer is restarted after each further byte is received. | |
fb186734 | 785 | .BR read (2) |
a9f0126f MK |
786 | returns when any of the following conditions is met: |
787 | .RS | |
22356d97 | 788 | .IP \(bu 3 |
a9f0126f | 789 | MIN bytes have been received. |
22356d97 | 790 | .IP \(bu |
a9f0126f | 791 | The interbyte timer expires. |
22356d97 | 792 | .IP \(bu |
a9f0126f MK |
793 | The number of bytes requested by |
794 | .BR read (2) | |
795 | has been received. | |
796 | (POSIX does not specify this termination condition, | |
797 | and on some other implementations | |
798 | .\" e.g., Solaris | |
8563c249 | 799 | .BR read (2) |
a9f0126f MK |
800 | does not return in this case.) |
801 | .RE | |
802 | .IP | |
33a0ccb2 | 803 | Because the timer is started only after the initial byte |
19ab0376 | 804 | becomes available, at least one byte will be read. |
e764d1b7 | 805 | If data is already available at the time of the call to |
8563c249 | 806 | .BR read (2), |
e764d1b7 | 807 | the call behaves as though the data was received immediately after the call. |
5ee2d3c5 MK |
808 | .PP |
809 | POSIX | |
810 | .\" POSIX.1-2008 XBD 11.1.7 | |
811 | does not specify whether the setting of the | |
812 | .B O_NONBLOCK | |
813 | file status flag takes precedence over the MIN and TIME settings. | |
814 | If | |
815 | .B O_NONBLOCK | |
816 | is set, a | |
8563c249 | 817 | .BR read (2) |
5ee2d3c5 MK |
818 | in noncanonical mode may return immediately, |
819 | regardless of the setting of MIN or TIME. | |
820 | Furthermore, if no data is available, | |
821 | POSIX permits a | |
8563c249 | 822 | .BR read (2) |
5ee2d3c5 MK |
823 | in noncanonical mode to return either 0, or \-1 with |
824 | .I errno | |
825 | set to | |
826 | .BR EAGAIN . | |
73d8cece | 827 | .SS Raw mode |
60a90ecd MK |
828 | .BR cfmakeraw () |
829 | sets the terminal to something like the | |
1954b6a9 | 830 | "raw" mode of the old Version 7 terminal driver: |
19ab0376 | 831 | input is available character by character, |
c13182ef | 832 | echoing is disabled, and all special processing of |
19ab0376 MK |
833 | terminal input and output characters is disabled. |
834 | The terminal attributes are set as follows: | |
a2b7a144 MK |
835 | .PP |
836 | .in +4n | |
837 | .EX | |
af2d18b2 | 838 | termios_p\->c_iflag &= \(ti(IGNBRK | BRKINT | PARMRK | ISTRIP |
a2b7a144 | 839 | | INLCR | IGNCR | ICRNL | IXON); |
af2d18b2 MK |
840 | termios_p\->c_oflag &= \(tiOPOST; |
841 | termios_p\->c_lflag &= \(ti(ECHO | ECHONL | ICANON | ISIG | IEXTEN); | |
842 | termios_p\->c_cflag &= \(ti(CSIZE | PARENB); | |
a2b7a144 MK |
843 | termios_p\->c_cflag |= CS8; |
844 | .EE | |
845 | .in | |
846 | .\" | |
73d8cece | 847 | .SS Line control |
63aa9df0 | 848 | .BR tcsendbreak () |
fea681da MK |
849 | transmits a continuous stream of zero-valued bits for a specific |
850 | duration, if the terminal is using asynchronous serial data | |
c13182ef MK |
851 | transmission. |
852 | If \fIduration\fP is zero, it transmits zero-valued bits | |
cf35dd37 | 853 | for at least 0.25 seconds, and not more than 0.5 seconds. |
c13182ef | 854 | If \fIduration\fP is not zero, it sends zero-valued bits for some |
fea681da | 855 | implementation-defined length of time. |
dd3568a1 | 856 | .PP |
fea681da | 857 | If the terminal is not using asynchronous serial data transmission, |
60a90ecd MK |
858 | .BR tcsendbreak () |
859 | returns without taking any action. | |
dd3568a1 | 860 | .PP |
63aa9df0 | 861 | .BR tcdrain () |
fea681da MK |
862 | waits until all output written to the object referred to by |
863 | .I fd | |
864 | has been transmitted. | |
dd3568a1 | 865 | .PP |
63aa9df0 | 866 | .BR tcflush () |
fea681da MK |
867 | discards data written to the object referred to by |
868 | .I fd | |
869 | but not transmitted, or data received but not read, depending on the | |
870 | value of | |
871 | .IR queue_selector : | |
4279e42d AC |
872 | .TP |
873 | .B TCIFLUSH | |
fea681da | 874 | flushes data received but not read. |
4279e42d AC |
875 | .TP |
876 | .B TCOFLUSH | |
fea681da | 877 | flushes data written but not transmitted. |
4279e42d AC |
878 | .TP |
879 | .B TCIOFLUSH | |
fea681da MK |
880 | flushes both data received but not read, and data written but not |
881 | transmitted. | |
dd3568a1 | 882 | .PP |
63aa9df0 | 883 | .BR tcflow () |
fea681da MK |
884 | suspends transmission or reception of data on the object referred to by |
885 | .IR fd , | |
886 | depending on the value of | |
887 | .IR action : | |
4279e42d AC |
888 | .TP |
889 | .B TCOOFF | |
fea681da | 890 | suspends output. |
4279e42d AC |
891 | .TP |
892 | .B TCOON | |
fea681da | 893 | restarts suspended output. |
4279e42d AC |
894 | .TP |
895 | .B TCIOFF | |
c13182ef | 896 | transmits a STOP character, which stops the terminal device from |
35478399 | 897 | transmitting data to the system. |
4279e42d AC |
898 | .TP |
899 | .B TCION | |
c13182ef | 900 | transmits a START character, which starts the terminal device |
35478399 | 901 | transmitting data to the system. |
dd3568a1 | 902 | .PP |
fea681da MK |
903 | The default on open of a terminal file is that neither its input nor its |
904 | output is suspended. | |
73d8cece | 905 | .SS Line speed |
87d1fd87 | 906 | The baud rate functions are provided for getting and setting the values |
c13182ef MK |
907 | of the input and output baud rates in the \fItermios\fP structure. |
908 | The new values do not take effect | |
60a90ecd MK |
909 | until |
910 | .BR tcsetattr () | |
911 | is successfully called. | |
847e0d88 | 912 | .PP |
87d1fd87 MK |
913 | Setting the speed to \fBB0\fP instructs the modem to "hang up". |
914 | The actual bit rate corresponding to \fBB38400\fP may be altered with | |
60a90ecd | 915 | .BR setserial (8). |
dd3568a1 | 916 | .PP |
87d1fd87 MK |
917 | The input and output baud rates are stored in the \fItermios\fP |
918 | structure. | |
dd3568a1 | 919 | .PP |
63aa9df0 | 920 | .BR cfgetospeed () |
869ebe5b | 921 | returns the output baud rate stored in the \fItermios\fP structure |
fea681da MK |
922 | pointed to by |
923 | .IR termios_p . | |
dd3568a1 | 924 | .PP |
63aa9df0 | 925 | .BR cfsetospeed () |
869ebe5b | 926 | sets the output baud rate stored in the \fItermios\fP structure pointed |
fea681da | 927 | to by \fItermios_p\fP to \fIspeed\fP, which must be one of these constants: |
9ce887ad AC |
928 | .RS |
929 | .TP | |
930 | .B B0 | |
931 | .TQ | |
932 | .B B50 | |
933 | .TQ | |
934 | .B B75 | |
935 | .TQ | |
936 | .B B110 | |
937 | .TQ | |
938 | .B B134 | |
939 | .TQ | |
940 | .B B150 | |
941 | .TQ | |
942 | .B B200 | |
943 | .TQ | |
944 | .B B300 | |
945 | .TQ | |
946 | .B B600 | |
947 | .TQ | |
948 | .B B1200 | |
949 | .TQ | |
950 | .B B1800 | |
951 | .TQ | |
952 | .B B2400 | |
953 | .TQ | |
954 | .B B4800 | |
955 | .TQ | |
956 | .B B9600 | |
957 | .TQ | |
958 | .B B19200 | |
959 | .TQ | |
960 | .B B38400 | |
961 | .TQ | |
962 | .B B57600 | |
963 | .TQ | |
964 | .B B115200 | |
965 | .TQ | |
966 | .B B230400 | |
967 | .TQ | |
968 | .B B460800 | |
969 | .TQ | |
970 | .B B500000 | |
971 | .TQ | |
972 | .B B576000 | |
973 | .TQ | |
974 | .B B921600 | |
975 | .TQ | |
976 | .B B1000000 | |
977 | .TQ | |
978 | .B B1152000 | |
979 | .TQ | |
980 | .B B1500000 | |
981 | .TQ | |
982 | .B B2000000 | |
983 | .RE | |
19ddd96b PR |
984 | .PP |
985 | These constants are additionally supported on the SPARC architecture: | |
9ce887ad AC |
986 | .RS |
987 | .TP | |
988 | .B B76800 | |
989 | .TQ | |
990 | .B B153600 | |
991 | .TQ | |
992 | .B B307200 | |
993 | .TQ | |
994 | .B B614400 | |
995 | .RE | |
19ddd96b PR |
996 | .PP |
997 | These constants are additionally supported on non-SPARC architectures: | |
9ce887ad AC |
998 | .RS |
999 | .TP | |
1000 | .B B2500000 | |
1001 | .TQ | |
1002 | .B B3000000 | |
1003 | .TQ | |
1004 | .B B3500000 | |
1005 | .TQ | |
1006 | .B B4000000 | |
1007 | .RE | |
a2b7a144 | 1008 | .PP |
19ddd96b PR |
1009 | Due to differences between architectures, portable applications should check |
1010 | if a particular | |
1011 | .BI B nnn | |
1012 | constant is defined prior to using it. | |
1013 | .PP | |
a53fba5e AC |
1014 | The zero baud rate, |
1015 | .BR B0 , | |
c13182ef | 1016 | is used to terminate the connection. |
15af0ac1 PR |
1017 | If |
1018 | .B B0 | |
1019 | is specified, the modem control lines shall no longer be asserted. | |
be7fff26 | 1020 | Normally, this will disconnect the line. |
a53fba5e AC |
1021 | .B CBAUDEX |
1022 | is a mask | |
fea681da | 1023 | for the speeds beyond those defined in POSIX.1 (57600 and above). |
a53fba5e AC |
1024 | Thus, |
1025 | .BR B57600 " & " CBAUDEX | |
1026 | is nonzero. | |
dd3568a1 | 1027 | .PP |
4e972a7c | 1028 | Setting the baud rate to a value other than those defined by |
a53fba5e | 1029 | .BI B nnn |
4e972a7c PR |
1030 | constants is possible via the |
1031 | .B TCSETS2 | |
1032 | ioctl; see | |
1033 | .BR ioctl_tty (2). | |
1034 | .PP | |
63aa9df0 | 1035 | .BR cfgetispeed () |
a53fba5e AC |
1036 | returns the input baud rate stored in the |
1037 | .I termios | |
1038 | structure. | |
dd3568a1 | 1039 | .PP |
63aa9df0 | 1040 | .BR cfsetispeed () |
a53fba5e AC |
1041 | sets the input baud rate stored in the |
1042 | .I termios | |
1043 | structure to | |
c13182ef | 1044 | .IR speed , |
a53fba5e AC |
1045 | which must be specified as one of the |
1046 | .BI B nnn | |
1047 | constants listed above for | |
869ebe5b | 1048 | .BR cfsetospeed (). |
847487d1 | 1049 | If the input baud rate is set to the literal constant |
4d3e4af3 PR |
1050 | .B 0 |
1051 | (not the symbolic constant | |
1052 | .BR B0 ), | |
1053 | the input baud rate will be | |
fea681da | 1054 | equal to the output baud rate. |
dd3568a1 | 1055 | .PP |
63aa9df0 | 1056 | .BR cfsetspeed () |
c13182ef MK |
1057 | is a 4.4BSD extension. |
1058 | It takes the same arguments as | |
869ebe5b MK |
1059 | .BR cfsetispeed (), |
1060 | and sets both input and output speed. | |
47297adb | 1061 | .SH RETURN VALUE |
63aa9df0 | 1062 | .BR cfgetispeed () |
fea681da | 1063 | returns the input baud rate stored in the |
869ebe5b | 1064 | \fItermios\fP |
fea681da | 1065 | structure. |
dd3568a1 | 1066 | .PP |
63aa9df0 | 1067 | .BR cfgetospeed () |
869ebe5b | 1068 | returns the output baud rate stored in the \fItermios\fP structure. |
dd3568a1 | 1069 | .PP |
fea681da | 1070 | All other functions return: |
4279e42d AC |
1071 | .TP |
1072 | .B 0 | |
fea681da | 1073 | on success. |
4279e42d AC |
1074 | .TP |
1075 | .B \-1 | |
fea681da MK |
1076 | on failure and set |
1077 | .I errno | |
1078 | to indicate the error. | |
dd3568a1 | 1079 | .PP |
fea681da | 1080 | Note that |
f87925c6 | 1081 | .BR tcsetattr () |
fea681da | 1082 | returns success if \fIany\fP of the requested changes could be |
c13182ef MK |
1083 | successfully carried out. |
1084 | Therefore, when making multiple changes | |
fea681da | 1085 | it may be necessary to follow this call with a further call to |
f87925c6 | 1086 | .BR tcgetattr () |
fea681da | 1087 | to check that all changes have been performed successfully. |
2be8b1b2 | 1088 | .SH ATTRIBUTES |
146c2ef3 PH |
1089 | For an explanation of the terms used in this section, see |
1090 | .BR attributes (7). | |
1091 | .nh | |
1092 | .ad l | |
c466875e | 1093 | .nh |
146c2ef3 PH |
1094 | .TS |
1095 | allbox; | |
c466875e | 1096 | lbx lb lb |
84a15261 | 1097 | l l l. |
146c2ef3 PH |
1098 | Interface Attribute Value |
1099 | T{ | |
2be8b1b2 PH |
1100 | .BR tcgetattr (), |
1101 | .BR tcsetattr (), | |
2be8b1b2 PH |
1102 | .BR tcdrain (), |
1103 | .BR tcflush (), | |
ff548faa | 1104 | .BR tcflow (), |
b2a64861 | 1105 | .BR tcsendbreak (), |
2be8b1b2 PH |
1106 | .BR cfmakeraw (), |
1107 | .BR cfgetispeed (), | |
1108 | .BR cfgetospeed (), | |
1109 | .BR cfsetispeed (), | |
1110 | .BR cfsetospeed (), | |
2be8b1b2 | 1111 | .BR cfsetspeed () |
7a075792 MK |
1112 | T} Thread safety MT-Safe |
1113 | .TE | |
c466875e MK |
1114 | .hy |
1115 | .ad | |
1116 | .sp 1 | |
7a075792 MK |
1117 | .\" FIXME: The markings are different from that in the glibc manual. |
1118 | .\" markings in glibc manual are more detailed: | |
1119 | .\" | |
1120 | .\" tcsendbreak: MT-Unsafe race:tcattr(filedes)/bsd | |
1121 | .\" tcflow: MT-Unsafe race:tcattr(filedes)/bsd | |
1122 | .\" | |
b6c73e0b | 1123 | .\" glibc manual says /bsd indicate the preceding marker only applies |
6e8ccc0d | 1124 | .\" when the underlying kernel is a BSD kernel. |
b6c73e0b | 1125 | .\" So, it is safety in Linux kernel. |
146c2ef3 | 1126 | .hy |
3113c7f3 | 1127 | .SH STANDARDS |
dfb631a8 MK |
1128 | .BR tcgetattr (), |
1129 | .BR tcsetattr (), | |
1130 | .BR tcsendbreak (), | |
1131 | .BR tcdrain (), | |
1132 | .BR tcflush (), | |
1133 | .BR tcflow (), | |
1134 | .BR cfgetispeed (), | |
1135 | .BR cfgetospeed (), | |
1136 | .BR cfsetispeed (), | |
1137 | and | |
1138 | .BR cfsetospeed () | |
1139 | are specified in POSIX.1-2001. | |
847e0d88 | 1140 | .PP |
dfb631a8 | 1141 | .BR cfmakeraw () |
01d5d366 MK |
1142 | and |
1143 | .BR cfsetspeed () | |
c8f2dd47 | 1144 | are nonstandard, but available on the BSDs. |
fea681da | 1145 | .SH NOTES |
b4112efb | 1146 | UNIX\ V7 and several later systems have a list of baud rates |
d192b1c7 | 1147 | where after the values |
1ae6b2c7 | 1148 | .B B0 |
d192b1c7 | 1149 | through |
69452aad PR |
1150 | .B B9600 |
1151 | one finds the two constants | |
1152 | .BR EXTA , | |
1153 | .B EXTB | |
1154 | ("External A" and "External B"). | |
fea681da | 1155 | Many systems extend the list with much higher baud rates. |
dd3568a1 | 1156 | .PP |
c7094399 | 1157 | The effect of a nonzero \fIduration\fP with |
60a90ecd MK |
1158 | .BR tcsendbreak () |
1159 | varies. | |
c13182ef | 1160 | SunOS specifies a break of |
8b8d0001 | 1161 | .I "duration\ *\ N" |
fea681da MK |
1162 | seconds, where \fIN\fP is at least 0.25, and not more than 0.5. |
1163 | Linux, AIX, DU, Tru64 send a break of | |
1164 | .I duration | |
1165 | milliseconds. | |
1166 | FreeBSD and NetBSD and HP-UX and MacOS ignore the value of | |
1167 | .IR duration . | |
1f409d5d | 1168 | Under Solaris and UnixWare, |
e511ffb6 | 1169 | .BR tcsendbreak () |
c7094399 | 1170 | with nonzero |
fea681da MK |
1171 | .I duration |
1172 | behaves like | |
e511ffb6 | 1173 | .BR tcdrain (). |
fea681da MK |
1174 | .\" libc4 until 4.7.5, glibc for sysv: EINVAL for duration > 0. |
1175 | .\" libc4.7.6, libc5, glibc for unix: duration in ms. | |
1176 | .\" glibc for bsd: duration in us | |
1177 | .\" glibc for sunos4: ignore duration | |
499eb81f ES |
1178 | .SH BUGS |
1179 | .\" kernel 77e5bff1640432f28794a00800955e646dcd7455 | |
1180 | .\" glibc 573963e32ffac46d9891970ddebde2ac3212c5c0 | |
ff2c4618 | 1181 | On the Alpha architecture before Linux 4.16 (and glibc before 2.28), the |
499eb81f | 1182 | .B XTABS |
ff2c4618 | 1183 | value was different from |
499eb81f ES |
1184 | .B TAB3 |
1185 | and it was ignored by the | |
1186 | .B N_TTY | |
ff2c4618 MK |
1187 | line discipline code of the terminal driver as a result |
1188 | (because as it wasn't part of the | |
499eb81f ES |
1189 | .B TABDLY |
1190 | mask). | |
47297adb | 1191 | .SH SEE ALSO |
c04700fb MK |
1192 | .BR reset (1), |
1193 | .BR setterm (1), | |
fea681da | 1194 | .BR stty (1), |
c04700fb | 1195 | .BR tput (1), |
ca8c33fc | 1196 | .BR tset (1), |
271ee1bf | 1197 | .BR tty (1), |
d49a2220 | 1198 | .BR ioctl_console (2), |
a9168840 | 1199 | .BR ioctl_tty (2), |
96f55464 | 1200 | .BR cc_t (3type), |
1201 | .BR speed_t (3type), | |
1202 | .BR tcflag_t (3type), | |
fea681da | 1203 | .BR setserial (8) |