]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1993 Michael Haardt |
2 | .\" (michael@moria.de) | |
3 | .\" Fri Apr 2 11:32:09 MET DST 1993 | |
4 | .\" | |
5 | .\" This is free documentation; you can redistribute it and/or | |
6 | .\" modify it under the terms of the GNU General Public License as | |
7 | .\" published by the Free Software Foundation; either version 2 of | |
8 | .\" the License, or (at your option) any later version. | |
9 | .\" | |
10 | .\" The GNU General Public License's references to "object code" | |
11 | .\" and "executables" are to be interpreted as the output of any | |
12 | .\" document formatting or typesetting system, including | |
13 | .\" intermediate and printed output. | |
14 | .\" | |
15 | .\" This manual is distributed in the hope that it will be useful, | |
16 | .\" but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | .\" GNU General Public License for more details. | |
19 | .\" | |
20 | .\" You should have received a copy of the GNU General Public | |
21 | .\" License along with this manual; if not, write to the Free | |
22 | .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, | |
23 | .\" USA. | |
24 | .\" | |
25 | .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu> | |
26 | .\" Modified 1995-02-25 by Jim Van Zandt <jrv@vanzandt.mv.com> | |
27 | .\" Modified 1995-09-02 by Jim Van Zandt <jrv@vanzandt.mv.com> | |
28 | .\" moved to man3, aeb, 950919 | |
c11b1abf | 29 | .\" Modified 2001-09-22 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da MK |
30 | .\" Modified 2001-12-17, aeb |
31 | .\" Modified 2004-10-31, aeb | |
19ab0376 MK |
32 | .\" 2006-12-28, mtk: |
33 | .\" Added .SS headers to give some structure to this page; and a | |
34 | .\" small amount of reordering. | |
a6712802 | 35 | .\" Added a section on canonical and noncanonical mode. |
19ab0376 MK |
36 | .\" Enhanced the discussion of "raw" mode for cfmakeraw(). |
37 | .\" Document CMSPAR. | |
fea681da | 38 | .\" |
d51529b8 | 39 | .TH TERMIOS 3 2011-09-08 "Linux" "Linux Programmer's Manual" |
fea681da MK |
40 | .SH NAME |
41 | termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, | |
42 | cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfsetspeed \- | |
43 | get and set terminal attributes, line control, get and set baud rate | |
44 | .SH SYNOPSIS | |
04bb6cc0 | 45 | .nf |
c91e381d | 46 | .B #include <termios.h> |
fea681da | 47 | .br |
c91e381d | 48 | .B #include <unistd.h> |
fea681da MK |
49 | .sp |
50 | .BI "int tcgetattr(int " fd ", struct termios *" termios_p ); | |
51 | .sp | |
04bb6cc0 MK |
52 | .BI "int tcsetattr(int " fd ", int " optional_actions , |
53 | .BI " const struct termios *" termios_p ); | |
fea681da MK |
54 | .sp |
55 | .BI "int tcsendbreak(int " fd ", int " duration ); | |
56 | .sp | |
57 | .BI "int tcdrain(int " fd ); | |
58 | .sp | |
59 | .BI "int tcflush(int " fd ", int " queue_selector ); | |
60 | .sp | |
61 | .BI "int tcflow(int " fd ", int " action ); | |
62 | .sp | |
63 | .BI "void cfmakeraw(struct termios *" termios_p ); | |
64 | .sp | |
65 | .BI "speed_t cfgetispeed(const struct termios *" termios_p ); | |
66 | .sp | |
67 | .BI "speed_t cfgetospeed(const struct termios *" termios_p ); | |
68 | .sp | |
69 | .BI "int cfsetispeed(struct termios *" termios_p ", speed_t " speed ); | |
70 | .sp | |
71 | .BI "int cfsetospeed(struct termios *" termios_p ", speed_t " speed ); | |
01d5d366 | 72 | .sp |
52dab97a | 73 | .BI "int cfsetspeed(struct termios *" termios_p ", speed_t " speed ); |
04bb6cc0 | 74 | .fi |
cc4615cc MK |
75 | .sp |
76 | .in -4n | |
77 | Feature Test Macro Requirements for glibc (see | |
78 | .BR feature_test_macros (7)): | |
79 | .in | |
80 | .sp | |
cc4615cc MK |
81 | .BR cfsetspeed (), |
82 | .BR cfmakeraw (): | |
83 | _BSD_SOURCE | |
fea681da MK |
84 | .SH DESCRIPTION |
85 | The termios functions describe a general terminal interface that is | |
86 | provided to control asynchronous communications ports. | |
73d8cece | 87 | .SS The termios structure |
fea681da MK |
88 | .LP |
89 | Many of the functions described here have a \fItermios_p\fP argument | |
c13182ef MK |
90 | that is a pointer to a \fItermios\fP structure. |
91 | This structure contains at least the following members: | |
fea681da | 92 | .sp |
a6e2f128 | 93 | .in +4n |
fea681da | 94 | .nf |
bd9b2a9c MK |
95 | tcflag_t c_iflag; /* input modes */ |
96 | tcflag_t c_oflag; /* output modes */ | |
97 | tcflag_t c_cflag; /* control modes */ | |
98 | tcflag_t c_lflag; /* local modes */ | |
d8b24e6e | 99 | cc_t c_cc[NCCS]; /* special characters */ |
fea681da | 100 | .fi |
a6e2f128 | 101 | .in |
fea681da | 102 | .PP |
869ebe5b | 103 | The values that may be assigned to these fields are described below. |
c13182ef MK |
104 | In the case of the first four bit-mask fields, |
105 | the definitions of some of the associated flags that may be set are | |
869ebe5b | 106 | only exposed if a specific feature test macro (see |
a8e7c990 | 107 | .BR feature_test_macros (7)) |
869ebe5b MK |
108 | is defined, as noted in brackets ("[]"). |
109 | .PP | |
42b09930 | 110 | In the descriptions below, "not in POSIX" means that the |
c13182ef MK |
111 | value is not specified in POSIX.1-2001, |
112 | and "XSI" means that the value is specified in POSIX.1-2001 | |
42b09930 MK |
113 | as part of the XSI extension. |
114 | .PP | |
fea681da MK |
115 | \fIc_iflag\fP flag constants: |
116 | .TP | |
117 | .B IGNBRK | |
118 | Ignore BREAK condition on input. | |
119 | .TP | |
120 | .B BRKINT | |
c13182ef MK |
121 | If \fBIGNBRK\fP is set, a BREAK is ignored. |
122 | If it is not set | |
fea681da MK |
123 | but \fBBRKINT\fP is set, then a BREAK causes the input and output |
124 | queues to be flushed, and if the terminal is the controlling | |
125 | terminal of a foreground process group, it will cause a | |
126 | \fBSIGINT\fP to be sent to this foreground process group. | |
127 | When neither \fBIGNBRK\fP nor \fBBRKINT\fP are set, a BREAK | |
f81fb444 | 128 | reads as a null byte (\(aq\\0\(aq), except when \fBPARMRK\fP is set, |
fea681da MK |
129 | in which case it reads as the sequence \\377 \\0 \\0. |
130 | .TP | |
131 | .B IGNPAR | |
132 | Ignore framing errors and parity errors. | |
133 | .TP | |
134 | .B PARMRK | |
c13182ef MK |
135 | If \fBIGNPAR\fP is not set, prefix a character with a parity error or |
136 | framing error with \\377 \\0. | |
137 | If neither \fBIGNPAR\fP nor \fBPARMRK\fP | |
fea681da MK |
138 | is set, read a character with a parity error or framing error |
139 | as \\0. | |
140 | .TP | |
141 | .B INPCK | |
142 | Enable input parity checking. | |
143 | .TP | |
144 | .B ISTRIP | |
145 | Strip off eighth bit. | |
146 | .TP | |
147 | .B INLCR | |
148 | Translate NL to CR on input. | |
149 | .TP | |
150 | .B IGNCR | |
151 | Ignore carriage return on input. | |
152 | .TP | |
153 | .B ICRNL | |
154 | Translate carriage return to newline on input (unless \fBIGNCR\fP is set). | |
155 | .TP | |
156 | .B IUCLC | |
157 | (not in POSIX) Map uppercase characters to lowercase on input. | |
158 | .TP | |
159 | .B IXON | |
160 | Enable XON/XOFF flow control on output. | |
161 | .TP | |
162 | .B IXANY | |
c13182ef | 163 | (XSI) Typing any character will restart stopped output. |
42b09930 | 164 | (The default is to allow just the START character to restart output.) |
fea681da MK |
165 | .TP |
166 | .B IXOFF | |
167 | Enable XON/XOFF flow control on input. | |
168 | .TP | |
169 | .B IMAXBEL | |
170 | (not in POSIX) Ring bell when input queue is full. | |
171 | Linux does not implement this bit, and acts as if it is always set. | |
225c76e9 MK |
172 | .TP |
173 | .BR IUTF8 " (since Linux 2.6.4)" | |
c13182ef | 174 | (not in POSIX) Input is UTF8; |
225c76e9 | 175 | this allows character-erase to be correctly performed in cooked mode. |
fea681da MK |
176 | .PP |
177 | \fIc_oflag\fP flag constants defined in POSIX.1: | |
178 | .TP | |
179 | .B OPOST | |
180 | Enable implementation-defined output processing. | |
181 | .PP | |
68e1685c | 182 | The remaining \fIc_oflag\fP flag constants are defined in POSIX.1-2001, |
fea681da MK |
183 | unless marked otherwise. |
184 | .TP | |
185 | .B OLCUC | |
186 | (not in POSIX) Map lowercase characters to uppercase on output. | |
187 | .TP | |
188 | .B ONLCR | |
189 | (XSI) Map NL to CR-NL on output. | |
190 | .TP | |
191 | .B OCRNL | |
192 | Map CR to NL on output. | |
193 | .TP | |
194 | .B ONOCR | |
195 | Don't output CR at column 0. | |
196 | .TP | |
197 | .B ONLRET | |
198 | Don't output CR. | |
199 | .TP | |
200 | .B OFILL | |
201 | Send fill characters for a delay, rather than using a timed delay. | |
202 | .TP | |
203 | .B OFDEL | |
204 | (not in POSIX) Fill character is ASCII DEL (0177). | |
f81fb444 | 205 | If unset, fill character is ASCII NUL (\(aq\\0\(aq). |
42b09930 | 206 | (Not implemented on Linux.) |
fea681da MK |
207 | .TP |
208 | .B NLDLY | |
c13182ef MK |
209 | Newline delay mask. |
210 | Values are \fBNL0\fP and \fBNL1\fP. | |
db4e96b7 MK |
211 | [requires |
212 | .B _BSD_SOURCE | |
213 | or | |
214 | .B _SVID_SOURCE | |
c90511a6 MK |
215 | or |
216 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
217 | .TP |
218 | .B CRDLY | |
219 | Carriage return delay mask. | |
220 | Values are \fBCR0\fP, \fBCR1\fP, \fBCR2\fP, or \fBCR3\fP. | |
db4e96b7 MK |
221 | [requires |
222 | .B _BSD_SOURCE | |
223 | or | |
224 | .B _SVID_SOURCE | |
c90511a6 MK |
225 | or |
226 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
227 | .TP |
228 | .B TABDLY | |
229 | Horizontal tab delay mask. | |
230 | Values are \fBTAB0\fP, \fBTAB1\fP, \fBTAB2\fP, \fBTAB3\fP (or \fBXTABS\fP). | |
231 | A value of TAB3, that is, XTABS, expands tabs to spaces | |
232 | (with tab stops every eight columns). | |
db4e96b7 MK |
233 | [requires |
234 | .B _BSD_SOURCE | |
235 | or | |
236 | .B _SVID_SOURCE | |
c90511a6 MK |
237 | or |
238 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
239 | .TP |
240 | .B BSDLY | |
c13182ef MK |
241 | Backspace delay mask. |
242 | Values are \fBBS0\fP or \fBBS1\fP. | |
fea681da | 243 | (Has never been implemented.) |
db4e96b7 MK |
244 | [requires |
245 | .B _BSD_SOURCE | |
246 | or | |
247 | .B _SVID_SOURCE | |
c90511a6 MK |
248 | or |
249 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
250 | .TP |
251 | .B VTDLY | |
c13182ef MK |
252 | Vertical tab delay mask. |
253 | Values are \fBVT0\fP or \fBVT1\fP. | |
fea681da MK |
254 | .TP |
255 | .B FFDLY | |
c13182ef MK |
256 | Form feed delay mask. |
257 | Values are \fBFF0\fP or \fBFF1\fP. | |
db4e96b7 MK |
258 | [requires |
259 | .B _BSD_SOURCE | |
260 | or | |
261 | .B _SVID_SOURCE | |
c90511a6 MK |
262 | or |
263 | .BR _XOPEN_SOURCE ] | |
fea681da MK |
264 | .PP |
265 | \fIc_cflag\fP flag constants: | |
266 | .TP | |
267 | .B CBAUD | |
268 | (not in POSIX) Baud speed mask (4+1 bits). | |
db4e96b7 MK |
269 | [requires |
270 | .B _BSD_SOURCE | |
c90511a6 MK |
271 | or |
272 | .BR _SVID_SOURCE ] | |
fea681da MK |
273 | .TP |
274 | .B CBAUDEX | |
097585ed MK |
275 | (not in POSIX) Extra baud speed mask (1 bit), included in |
276 | .BR CBAUD . | |
db4e96b7 MK |
277 | [requires |
278 | .B _BSD_SOURCE | |
c90511a6 MK |
279 | or |
280 | .BR _SVID_SOURCE ] | |
42b09930 | 281 | .sp |
c13182ef MK |
282 | (POSIX says that the baud speed is stored in the |
283 | .I termios | |
42b09930 | 284 | structure without specifying where precisely, and provides |
63aa9df0 | 285 | .BR cfgetispeed () |
fea681da | 286 | and |
63aa9df0 | 287 | .BR cfsetispeed () |
c13182ef | 288 | for getting at it. |
097585ed MK |
289 | Some systems use bits selected by |
290 | .B CBAUD | |
291 | in | |
fea681da | 292 | .IR c_cflag , |
75b94dc3 | 293 | other systems use separate fields, for example, |
fea681da MK |
294 | .I sg_ispeed |
295 | and | |
296 | .IR sg_ospeed .) | |
297 | .TP | |
298 | .B CSIZE | |
299 | Character size mask. | |
300 | Values are \fBCS5\fP, \fBCS6\fP, \fBCS7\fP, or \fBCS8\fP. | |
301 | .TP | |
302 | .B CSTOPB | |
303 | Set two stop bits, rather than one. | |
304 | .TP | |
305 | .B CREAD | |
306 | Enable receiver. | |
307 | .TP | |
308 | .B PARENB | |
309 | Enable parity generation on output and parity checking for input. | |
310 | .TP | |
311 | .B PARODD | |
c13182ef | 312 | If set, then parity for input and output is odd; |
19ab0376 | 313 | otherwise even parity is used. |
fea681da MK |
314 | .TP |
315 | .B HUPCL | |
316 | Lower modem control lines after last process closes the device (hang up). | |
317 | .TP | |
318 | .B CLOCAL | |
319 | Ignore modem control lines. | |
320 | .TP | |
321 | .B LOBLK | |
24b74457 | 322 | (not in POSIX) Block output from a noncurrent shell layer. |
42b09930 | 323 | For use by \fBshl\fP (shell layers). (Not implemented on Linux.) |
fea681da MK |
324 | .TP |
325 | .B CIBAUD | |
4a837837 | 326 | (not in POSIX) Mask for input speeds. |
097585ed MK |
327 | The values for the |
328 | .B CIBAUD | |
329 | bits are | |
330 | the same as the values for the | |
331 | .B CBAUD | |
332 | bits, shifted left | |
333 | .B IBSHIFT | |
334 | bits. | |
db4e96b7 MK |
335 | [requires |
336 | .B _BSD_SOURCE | |
c90511a6 MK |
337 | or |
338 | .BR _SVID_SOURCE ] | |
42b09930 | 339 | (Not implemented on Linux.) |
fea681da | 340 | .TP |
adab6032 | 341 | .B CMSPAR |
ad715af9 | 342 | (not in POSIX) |
c13182ef | 343 | Use "stick" (mark/space) parity (supported on certain serial |
4a837837 | 344 | devices): if |
c13182ef | 345 | .B PARODD |
adab6032 | 346 | is set, the parity bit is always 1; if |
c13182ef | 347 | .B PARODD |
adab6032 | 348 | is not set, then the parity bit is always 0). |
db4e96b7 MK |
349 | [requires |
350 | .B _BSD_SOURCE | |
c90511a6 MK |
351 | or |
352 | .BR _SVID_SOURCE ] | |
adab6032 | 353 | .TP |
fea681da MK |
354 | .B CRTSCTS |
355 | (not in POSIX) Enable RTS/CTS (hardware) flow control. | |
db4e96b7 MK |
356 | [requires |
357 | .B _BSD_SOURCE | |
c90511a6 MK |
358 | or |
359 | .BR _SVID_SOURCE ] | |
fea681da MK |
360 | .PP |
361 | \fIc_lflag\fP flag constants: | |
362 | .TP | |
363 | .B ISIG | |
364 | When any of the characters INTR, QUIT, SUSP, or DSUSP are received, | |
365 | generate the corresponding signal. | |
366 | .TP | |
367 | .B ICANON | |
c13182ef | 368 | Enable canonical mode (described below). |
fea681da MK |
369 | .TP |
370 | .B XCASE | |
371 | (not in POSIX; not supported under Linux) | |
372 | If \fBICANON\fP is also set, terminal is uppercase only. | |
373 | Input is converted to lowercase, except for characters preceded by \\. | |
374 | On output, uppercase characters are preceded by \\ and lowercase | |
375 | characters are converted to uppercase. | |
eee28e75 | 376 | [requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE] |
c3dfd2c8 | 377 | .\" glibc is probably now wrong to allow |
eee28e75 MK |
378 | .\" Define |
379 | .\" .B _XOPEN_SOURCE | |
380 | .\" to expose | |
381 | .\" .BR XCASE . | |
fea681da MK |
382 | .TP |
383 | .B ECHO | |
384 | Echo input characters. | |
385 | .TP | |
386 | .B ECHOE | |
387 | If \fBICANON\fP is also set, the ERASE character erases the preceding | |
388 | input character, and WERASE erases the preceding word. | |
389 | .TP | |
390 | .B ECHOK | |
391 | If \fBICANON\fP is also set, the KILL character erases the current line. | |
392 | .TP | |
393 | .B ECHONL | |
394 | If \fBICANON\fP is also set, echo the NL character even if ECHO is not set. | |
395 | .TP | |
396 | .B ECHOCTL | |
d8b24e6e MK |
397 | (not in POSIX) If \fBECHO\fP is also set, |
398 | terminal special characters other than | |
8bb93cd4 MK |
399 | TAB, NL, START, and STOP are echoed as \fB^X\fP, |
400 | where X is the character with | |
d8b24e6e | 401 | ASCII code 0x40 greater than the special character. |
c13182ef | 402 | For example, character |
8bb93cd4 | 403 | 0x08 (BS) is echoed as \fB^H\fP. |
db4e96b7 MK |
404 | [requires |
405 | .B _BSD_SOURCE | |
c90511a6 MK |
406 | or |
407 | .BR _SVID_SOURCE ] | |
fea681da MK |
408 | .TP |
409 | .B ECHOPRT | |
96da8065 | 410 | (not in POSIX) If \fBICANON\fP and \fBECHO\fP are also set, characters |
fea681da | 411 | are printed as they are being erased. |
db4e96b7 MK |
412 | [requires |
413 | .B _BSD_SOURCE | |
c90511a6 MK |
414 | or |
415 | .BR _SVID_SOURCE ] | |
fea681da MK |
416 | .TP |
417 | .B ECHOKE | |
418 | (not in POSIX) If \fBICANON\fP is also set, KILL is echoed by erasing | |
419 | each character on the line, as specified by \fBECHOE\fP and \fBECHOPRT\fP. | |
db4e96b7 MK |
420 | [requires |
421 | .B _BSD_SOURCE | |
c90511a6 MK |
422 | or |
423 | .BR _SVID_SOURCE ] | |
fea681da MK |
424 | .TP |
425 | .B DEFECHO | |
426 | (not in POSIX) Echo only when a process is reading. | |
42b09930 | 427 | (Not implemented on Linux.) |
fea681da MK |
428 | .TP |
429 | .B FLUSHO | |
430 | (not in POSIX; not supported under Linux) | |
c13182ef MK |
431 | Output is being flushed. |
432 | This flag is toggled by typing | |
fea681da | 433 | the DISCARD character. |
db4e96b7 MK |
434 | [requires |
435 | .B _BSD_SOURCE | |
c90511a6 MK |
436 | or |
437 | .BR _SVID_SOURCE ] | |
fea681da MK |
438 | .TP |
439 | .B NOFLSH | |
6e502d47 MK |
440 | Disable flushing the input and output queues when generating signals for the |
441 | INT, QUIT, and SUSP characters. | |
442 | .\" Stevens lets SUSP only flush the input queue | |
fea681da MK |
443 | .TP |
444 | .B TOSTOP | |
8bd58774 MK |
445 | Send the |
446 | .B SIGTTOU | |
447 | signal to the process group of a background process | |
fea681da MK |
448 | which tries to write to its controlling terminal. |
449 | .TP | |
450 | .B PENDIN | |
451 | (not in POSIX; not supported under Linux) | |
452 | All characters in the input queue are reprinted when | |
c13182ef | 453 | the next character is read. |
5852aba2 MK |
454 | .RB ( bash (1) |
455 | handles typeahead this way.) | |
db4e96b7 MK |
456 | [requires |
457 | .B _BSD_SOURCE | |
c90511a6 MK |
458 | or |
459 | .BR _SVID_SOURCE ] | |
fea681da MK |
460 | .TP |
461 | .B IEXTEN | |
462 | Enable implementation-defined input processing. | |
0425de01 | 463 | This flag, as well as \fBICANON\fP must be enabled for the |
fea681da MK |
464 | special characters EOL2, LNEXT, REPRINT, WERASE to be interpreted, |
465 | and for the \fBIUCLC\fP flag to be effective. | |
466 | .PP | |
d8b24e6e | 467 | The \fIc_cc\fP array defines the terminal special characters. |
fea681da MK |
468 | The symbolic indices (initial values) and meaning are: |
469 | .TP | |
91e2779f MK |
470 | .B VDISCARD |
471 | (not in POSIX; not supported under Linux; 017, SI, Ctrl-O) | |
472 | Toggle: start/stop discarding pending output. | |
097585ed | 473 | Recognized when |
91e2779f | 474 | .B IEXTEN |
097585ed | 475 | is set, and then not passed as input. |
fea681da | 476 | .TP |
91e2779f MK |
477 | .B VDSUSP |
478 | (not in POSIX; not supported under Linux; 031, EM, Ctrl-Y) | |
489e425d | 479 | Delayed suspend character (DSUSP): |
91e2779f MK |
480 | send |
481 | .B SIGTSTP | |
482 | signal when the character is read by the user program. | |
097585ed | 483 | Recognized when |
91e2779f MK |
484 | .B IEXTEN |
485 | and | |
097585ed | 486 | .B ISIG |
91e2779f MK |
487 | are set, and the system supports |
488 | job control, and then not passed as input. | |
fea681da MK |
489 | .TP |
490 | .B VEOF | |
491 | (004, EOT, Ctrl-D) | |
489e425d | 492 | End-of-file character (EOF). |
fea681da MK |
493 | More precisely: this character causes the pending tty buffer to be sent |
494 | to the waiting user program without waiting for end-of-line. | |
d9c1ae64 MK |
495 | If it is the first character of the line, the |
496 | .BR read (2) | |
497 | in the user program returns 0, which signifies end-of-file. | |
097585ed MK |
498 | Recognized when |
499 | .B ICANON | |
500 | is set, and then not passed as input. | |
fea681da | 501 | .TP |
fea681da MK |
502 | .B VEOL |
503 | (0, NUL) | |
489e425d | 504 | Additional end-of-line character (EOL). |
097585ed MK |
505 | Recognized when |
506 | .B ICANON | |
507 | is set. | |
fea681da | 508 | .TP |
fea681da MK |
509 | .B VEOL2 |
510 | (not in POSIX; 0, NUL) | |
489e425d | 511 | Yet another end-of-line character (EOL2). |
097585ed MK |
512 | Recognized when |
513 | .B ICANON | |
514 | is set. | |
fea681da | 515 | .TP |
91e2779f MK |
516 | .B VERASE |
517 | (0177, DEL, rubout, or 010, BS, Ctrl-H, or also #) | |
489e425d | 518 | Erase character (ERASE). |
91e2779f MK |
519 | This erases the previous not-yet-erased character, |
520 | but does not erase past EOF or beginning-of-line. | |
097585ed | 521 | Recognized when |
91e2779f | 522 | .B ICANON |
097585ed | 523 | is set, and then not passed as input. |
fea681da | 524 | .TP |
91e2779f MK |
525 | .B VINTR |
526 | (003, ETX, Ctrl-C, or also 0177, DEL, rubout) | |
489e425d | 527 | Interrupt character (INTR). |
91e2779f MK |
528 | Send a |
529 | .B SIGINT | |
8bd58774 | 530 | signal. |
097585ed MK |
531 | Recognized when |
532 | .B ISIG | |
533 | is set, and then not passed as input. | |
fea681da | 534 | .TP |
91e2779f MK |
535 | .B VKILL |
536 | (025, NAK, Ctrl-U, or Ctrl-X, or also @) | |
489e425d | 537 | Kill character (KILL). |
91e2779f | 538 | This erases the input since the last EOF or beginning-of-line. |
097585ed | 539 | Recognized when |
91e2779f MK |
540 | .B ICANON |
541 | is set, and then not passed as input. | |
fea681da MK |
542 | .TP |
543 | .B VLNEXT | |
544 | (not in POSIX; 026, SYN, Ctrl-V) | |
489e425d | 545 | Literal next (LNEXT). |
c13182ef | 546 | Quotes the next input character, depriving it of |
fea681da | 547 | a possible special meaning. |
097585ed MK |
548 | Recognized when |
549 | .B IEXTEN | |
550 | is set, and then not passed as input. | |
fea681da | 551 | .TP |
91e2779f | 552 | .B VMIN |
489e425d | 553 | Minimum number of characters for noncanonical read (MIN). |
91e2779f MK |
554 | .TP |
555 | .B VQUIT | |
31a6818e | 556 | (034, FS, Ctrl-\e) |
489e425d | 557 | Quit character (QUIT). |
91e2779f MK |
558 | Send |
559 | .B SIGQUIT | |
560 | signal. | |
097585ed | 561 | Recognized when |
91e2779f MK |
562 | .B ISIG |
563 | is set, and then not passed as input. | |
fea681da MK |
564 | .TP |
565 | .B VREPRINT | |
566 | (not in POSIX; 022, DC2, Ctrl-R) | |
489e425d | 567 | Reprint unread characters (REPRINT). |
097585ed MK |
568 | Recognized when |
569 | .B ICANON | |
570 | and | |
571 | .B IEXTEN | |
572 | are set, and then not passed as input. | |
fea681da | 573 | .TP |
91e2779f MK |
574 | .B VSTART |
575 | (021, DC1, Ctrl-Q) | |
489e425d | 576 | Start character (START). |
91e2779f | 577 | Restarts output stopped by the Stop character. |
097585ed | 578 | Recognized when |
91e2779f | 579 | .B IXON |
097585ed | 580 | is set, and then not passed as input. |
fea681da MK |
581 | .TP |
582 | .B VSTATUS | |
583 | (not in POSIX; not supported under Linux; | |
584 | status request: 024, DC4, Ctrl-T). | |
a6639d09 MK |
585 | Status character (STATUS). |
586 | Display status information at terminal, | |
587 | including state of foreground process and amount of CPU time it has consumed. | |
588 | Also sends a | |
589 | .BR SIGINFO | |
590 | signal (not supported on Linux) to the foreground process group. | |
91e2779f MK |
591 | .TP |
592 | .B VSTOP | |
593 | (023, DC3, Ctrl-S) | |
489e425d | 594 | Stop character (STOP). |
91e2779f MK |
595 | Stop output until Start character typed. |
596 | Recognized when | |
597 | .B IXON | |
598 | is set, and then not passed as input. | |
599 | .TP | |
600 | .B VSUSP | |
601 | (032, SUB, Ctrl-Z) | |
489e425d | 602 | Suspend character (SUSP). |
91e2779f MK |
603 | Send |
604 | .B SIGTSTP | |
605 | signal. | |
606 | Recognized when | |
607 | .B ISIG | |
608 | is set, and then not passed as input. | |
609 | .TP | |
610 | .B VSWTCH | |
611 | (not in POSIX; not supported under Linux; 0, NUL) | |
489e425d | 612 | Switch character (SWTCH). |
33b7fff5 MK |
613 | Used in System V to switch shells in |
614 | .IR "shell layers" , | |
5aaf78b7 | 615 | a predecessor to shell job control. |
91e2779f MK |
616 | .TP |
617 | .B VTIME | |
489e425d | 618 | Timeout in deciseconds for noncanonical read (TIME). |
91e2779f MK |
619 | .TP |
620 | .B VWERASE | |
621 | (not in POSIX; 027, ETB, Ctrl-W) | |
489e425d | 622 | Word erase (WERASE). |
91e2779f MK |
623 | Recognized when |
624 | .B ICANON | |
625 | and | |
626 | .B IEXTEN | |
627 | are set, and then not passed as input. | |
fea681da | 628 | .LP |
d51529b8 MK |
629 | An individual terminal special character can be disabled by setting |
630 | the value of the corresponding | |
631 | .I c_cc | |
632 | element to | |
633 | .BR _POSIX_VDISABLE . | |
634 | .LP | |
635 | The above symbolic subscript values are all different, except that | |
097585ed | 636 | .BR VTIME , |
0daa9e92 | 637 | .B VMIN |
097585ed | 638 | may have the same value as |
3cf81850 | 639 | .BR VEOL , |
097585ed MK |
640 | .BR VEOF , |
641 | respectively. | |
a6712802 | 642 | In noncanonical mode the special character meaning is replaced |
c13182ef | 643 | by the timeout meaning. |
097585ed MK |
644 | For an explanation of |
645 | .B VMIN | |
646 | and | |
647 | .BR VTIME , | |
648 | see the description of | |
a6712802 | 649 | noncanonical mode below. |
73d8cece | 650 | .SS Retrieving and changing terminal settings |
fea681da | 651 | .PP |
63aa9df0 | 652 | .BR tcgetattr () |
fea681da | 653 | gets the parameters associated with the object referred by \fIfd\fP and |
869ebe5b | 654 | stores them in the \fItermios\fP structure referenced by |
c13182ef MK |
655 | \fItermios_p\fP. |
656 | This function may be invoked from a background process; | |
fea681da MK |
657 | however, the terminal attributes may be subsequently changed by a |
658 | foreground process. | |
659 | .LP | |
63aa9df0 | 660 | .BR tcsetattr () |
fea681da MK |
661 | sets the parameters associated with the terminal (unless support is |
662 | required from the underlying hardware that is not available) from the | |
c13182ef | 663 | \fItermios\fP structure referred to by \fItermios_p\fP. |
fea681da MK |
664 | \fIoptional_actions\fP specifies when the changes take effect: |
665 | .IP \fBTCSANOW\fP | |
666 | the change occurs immediately. | |
667 | .IP \fBTCSADRAIN\fP | |
668 | the change occurs after all output written to | |
669 | .I fd | |
c13182ef MK |
670 | has been transmitted. |
671 | This function should be used when changing | |
fea681da MK |
672 | parameters that affect output. |
673 | .IP \fBTCSAFLUSH\fP | |
674 | the change occurs after all output written to the object referred by | |
675 | .I fd | |
676 | has been transmitted, and all input that has been received but not read | |
677 | will be discarded before the change is made. | |
73d8cece | 678 | .SS Canonical and noncanonical mode |
19ab0376 MK |
679 | The setting of the |
680 | .B ICANON | |
681 | canon flag in | |
682 | .I c_lflag | |
683 | determines whether the terminal is operating in canonical mode | |
684 | .RB ( ICANON | |
685 | set) or | |
a6712802 | 686 | noncanonical mode |
c13182ef | 687 | .RB ( ICANON |
19ab0376 MK |
688 | unset). |
689 | By default, | |
690 | .B ICANON | |
691 | set. | |
692 | ||
693 | In canonical mode: | |
694 | .IP * 2 | |
695 | Input is made available line by line. | |
696 | An input line is available when one of the line delimiters | |
697 | is typed (NL, EOL, EOL2; or EOF at the start of line). | |
698 | Except in the case of EOF, the line delimiter is included | |
699 | in the buffer returned by | |
700 | .BR read (2). | |
701 | .IP * 2 | |
c13182ef MK |
702 | Line editing is enabled (ERASE, KILL; |
703 | and if the | |
19ab0376 MK |
704 | .B IEXTEN |
705 | flag is set: WERASE, REPRINT, LNEXT). | |
c13182ef | 706 | A |
fb186734 | 707 | .BR read (2) |
19ab0376 | 708 | returns at most one line of input; if the |
fb186734 | 709 | .BR read (2) |
19ab0376 MK |
710 | requested fewer bytes than are available in the current line of input, |
711 | then only as many bytes as requested are read, | |
712 | and the remaining characters will be available for a future | |
fb186734 | 713 | .BR read (2). |
19ab0376 | 714 | .PP |
a6712802 | 715 | In noncanonical mode input is available immediately (without |
19ab0376 MK |
716 | the user having to type a line-delimiter character), |
717 | and line editing is disabled. | |
c13182ef | 718 | The settings of MIN |
19ab0376 | 719 | .RI ( c_cc[VMIN] ) |
0f8b10eb | 720 | and TIME |
19ab0376 MK |
721 | .RI ( c_cc[VTIME] ) |
722 | determine the circumstances in which a | |
723 | .BR read (2) | |
724 | completes; there are four distinct cases: | |
725 | .IP * 2 | |
726 | MIN == 0; TIME == 0: | |
727 | If data is available, | |
fb186734 | 728 | .BR read (2) |
19ab0376 MK |
729 | returns immediately, with the lesser of the number of bytes |
730 | available, or the number of bytes requested. | |
731 | If no data is available, | |
fb186734 | 732 | .BR read (2) |
19ab0376 MK |
733 | returns 0. |
734 | .IP * 2 | |
735 | MIN > 0; TIME == 0: | |
fb186734 | 736 | .BR read (2) |
19ab0376 MK |
737 | blocks until the lesser of MIN bytes or the number of bytes requested |
738 | are available, and returns the lesser of these two values. | |
739 | .IP * 2 | |
740 | MIN == 0; TIME > 0: | |
741 | TIME specifies the limit for a timer in tenths of a second. | |
c13182ef | 742 | The timer is started when |
fb186734 | 743 | .BR read (2) |
19ab0376 | 744 | is called. |
fb186734 | 745 | .BR read (2) |
19ab0376 MK |
746 | returns either when at least one byte of data is available, |
747 | or when the timer expires. | |
748 | If the timer expires without any input becoming available, | |
fb186734 | 749 | .BR read (2) |
19ab0376 MK |
750 | returns 0. |
751 | .IP * 2 | |
752 | MIN > 0; TIME > 0: | |
753 | TIME specifies the limit for a timer in tenths of a second. | |
754 | Once an initial byte of input becomes available, | |
755 | the timer is restarted after each further byte is received. | |
fb186734 | 756 | .BR read (2) |
c13182ef | 757 | returns either when the lesser of the number of bytes requested or |
19ab0376 MK |
758 | MIN byte have been read, |
759 | or when the inter-byte timeout expires. | |
c13182ef | 760 | Because the timer is only started after the initial byte |
19ab0376 | 761 | becomes available, at least one byte will be read. |
73d8cece | 762 | .SS Raw mode |
19ab0376 | 763 | .LP |
60a90ecd MK |
764 | .BR cfmakeraw () |
765 | sets the terminal to something like the | |
1954b6a9 | 766 | "raw" mode of the old Version 7 terminal driver: |
19ab0376 | 767 | input is available character by character, |
c13182ef | 768 | echoing is disabled, and all special processing of |
19ab0376 MK |
769 | terminal input and output characters is disabled. |
770 | The terminal attributes are set as follows: | |
771 | .nf | |
772 | ||
94e9d9fe | 773 | termios_p\->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |
19ab0376 | 774 | | INLCR | IGNCR | ICRNL | IXON); |
94e9d9fe MK |
775 | termios_p\->c_oflag &= ~OPOST; |
776 | termios_p\->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); | |
777 | termios_p\->c_cflag &= ~(CSIZE | PARENB); | |
778 | termios_p\->c_cflag |= CS8; | |
19ab0376 | 779 | .fi |
73d8cece | 780 | .SS Line control |
fea681da | 781 | .LP |
63aa9df0 | 782 | .BR tcsendbreak () |
fea681da MK |
783 | transmits a continuous stream of zero-valued bits for a specific |
784 | duration, if the terminal is using asynchronous serial data | |
c13182ef MK |
785 | transmission. |
786 | If \fIduration\fP is zero, it transmits zero-valued bits | |
787 | for at least 0.25 seconds, and not more that 0.5 seconds. | |
788 | If \fIduration\fP is not zero, it sends zero-valued bits for some | |
fea681da MK |
789 | implementation-defined length of time. |
790 | .LP | |
791 | If the terminal is not using asynchronous serial data transmission, | |
60a90ecd MK |
792 | .BR tcsendbreak () |
793 | returns without taking any action. | |
fea681da | 794 | .LP |
63aa9df0 | 795 | .BR tcdrain () |
fea681da MK |
796 | waits until all output written to the object referred to by |
797 | .I fd | |
798 | has been transmitted. | |
799 | .LP | |
63aa9df0 | 800 | .BR tcflush () |
fea681da MK |
801 | discards data written to the object referred to by |
802 | .I fd | |
803 | but not transmitted, or data received but not read, depending on the | |
804 | value of | |
805 | .IR queue_selector : | |
806 | .IP \fBTCIFLUSH\fP | |
807 | flushes data received but not read. | |
808 | .IP \fBTCOFLUSH\fP | |
809 | flushes data written but not transmitted. | |
810 | .IP \fBTCIOFLUSH\fP | |
811 | flushes both data received but not read, and data written but not | |
812 | transmitted. | |
813 | .LP | |
63aa9df0 | 814 | .BR tcflow () |
fea681da MK |
815 | suspends transmission or reception of data on the object referred to by |
816 | .IR fd , | |
817 | depending on the value of | |
818 | .IR action : | |
819 | .IP \fBTCOOFF\fP | |
820 | suspends output. | |
821 | .IP \fBTCOON\fP | |
822 | restarts suspended output. | |
823 | .IP \fBTCIOFF\fP | |
c13182ef | 824 | transmits a STOP character, which stops the terminal device from |
35478399 | 825 | transmitting data to the system. |
fea681da | 826 | .IP \fBTCION\fP |
c13182ef | 827 | transmits a START character, which starts the terminal device |
35478399 | 828 | transmitting data to the system. |
fea681da MK |
829 | .LP |
830 | The default on open of a terminal file is that neither its input nor its | |
831 | output is suspended. | |
73d8cece | 832 | .SS Line speed |
87d1fd87 | 833 | The baud rate functions are provided for getting and setting the values |
c13182ef MK |
834 | of the input and output baud rates in the \fItermios\fP structure. |
835 | The new values do not take effect | |
60a90ecd MK |
836 | until |
837 | .BR tcsetattr () | |
838 | is successfully called. | |
87d1fd87 MK |
839 | |
840 | Setting the speed to \fBB0\fP instructs the modem to "hang up". | |
841 | The actual bit rate corresponding to \fBB38400\fP may be altered with | |
60a90ecd | 842 | .BR setserial (8). |
87d1fd87 MK |
843 | .LP |
844 | The input and output baud rates are stored in the \fItermios\fP | |
845 | structure. | |
fea681da | 846 | .LP |
63aa9df0 | 847 | .BR cfgetospeed () |
869ebe5b | 848 | returns the output baud rate stored in the \fItermios\fP structure |
fea681da MK |
849 | pointed to by |
850 | .IR termios_p . | |
851 | .LP | |
63aa9df0 | 852 | .BR cfsetospeed () |
869ebe5b | 853 | sets the output baud rate stored in the \fItermios\fP structure pointed |
fea681da MK |
854 | to by \fItermios_p\fP to \fIspeed\fP, which must be one of these constants: |
855 | .nf | |
869ebe5b | 856 | |
fea681da MK |
857 | .ft B |
858 | B0 | |
859 | B50 | |
860 | B75 | |
861 | B110 | |
862 | B134 | |
863 | B150 | |
864 | B200 | |
865 | B300 | |
866 | B600 | |
867 | B1200 | |
868 | B1800 | |
869 | B2400 | |
870 | B4800 | |
871 | B9600 | |
872 | B19200 | |
873 | B38400 | |
874 | B57600 | |
875 | B115200 | |
876 | B230400 | |
877 | .ft P | |
869ebe5b | 878 | |
fea681da MK |
879 | .fi |
880 | The zero baud rate, \fBB0\fP, | |
c13182ef MK |
881 | is used to terminate the connection. |
882 | If B0 is specified, the modem control lines shall no longer be asserted. | |
be7fff26 MK |
883 | Normally, this will disconnect the line. |
884 | \fBCBAUDEX\fP is a mask | |
fea681da | 885 | for the speeds beyond those defined in POSIX.1 (57600 and above). |
c7094399 | 886 | Thus, \fBB57600\fP & \fBCBAUDEX\fP is nonzero. |
fea681da | 887 | .LP |
63aa9df0 | 888 | .BR cfgetispeed () |
869ebe5b | 889 | returns the input baud rate stored in the \fItermios\fP structure. |
fea681da | 890 | .LP |
63aa9df0 | 891 | .BR cfsetispeed () |
869ebe5b | 892 | sets the input baud rate stored in the \fItermios\fP structure to |
c13182ef | 893 | .IR speed , |
869ebe5b MK |
894 | which must be specified as one of the \fBBnnn\fP constants listed above for |
895 | .BR cfsetospeed (). | |
fea681da MK |
896 | If the input baud rate is set to zero, the input baud rate will be |
897 | equal to the output baud rate. | |
898 | .LP | |
63aa9df0 | 899 | .BR cfsetspeed () |
c13182ef MK |
900 | is a 4.4BSD extension. |
901 | It takes the same arguments as | |
869ebe5b MK |
902 | .BR cfsetispeed (), |
903 | and sets both input and output speed. | |
47297adb | 904 | .SH RETURN VALUE |
fea681da | 905 | .LP |
63aa9df0 | 906 | .BR cfgetispeed () |
fea681da | 907 | returns the input baud rate stored in the |
869ebe5b | 908 | \fItermios\fP |
fea681da MK |
909 | structure. |
910 | .LP | |
63aa9df0 | 911 | .BR cfgetospeed () |
869ebe5b | 912 | returns the output baud rate stored in the \fItermios\fP structure. |
fea681da MK |
913 | .LP |
914 | All other functions return: | |
915 | .IP 0 | |
916 | on success. | |
917 | .IP \-1 | |
918 | on failure and set | |
919 | .I errno | |
920 | to indicate the error. | |
921 | .LP | |
922 | Note that | |
f87925c6 | 923 | .BR tcsetattr () |
fea681da | 924 | returns success if \fIany\fP of the requested changes could be |
c13182ef MK |
925 | successfully carried out. |
926 | Therefore, when making multiple changes | |
fea681da | 927 | it may be necessary to follow this call with a further call to |
f87925c6 | 928 | .BR tcgetattr () |
fea681da | 929 | to check that all changes have been performed successfully. |
dfb631a8 MK |
930 | .SH CONFORMING TO |
931 | .BR tcgetattr (), | |
932 | .BR tcsetattr (), | |
933 | .BR tcsendbreak (), | |
934 | .BR tcdrain (), | |
935 | .BR tcflush (), | |
936 | .BR tcflow (), | |
937 | .BR cfgetispeed (), | |
938 | .BR cfgetospeed (), | |
939 | .BR cfsetispeed (), | |
940 | and | |
941 | .BR cfsetospeed () | |
942 | are specified in POSIX.1-2001. | |
943 | ||
944 | .BR cfmakeraw () | |
01d5d366 MK |
945 | and |
946 | .BR cfsetspeed () | |
c8f2dd47 | 947 | are nonstandard, but available on the BSDs. |
fea681da | 948 | .SH NOTES |
1f409d5d | 949 | UNIX V7 and several later systems have a list of baud rates |
fea681da MK |
950 | where after the fourteen values B0, ..., B9600 one finds the |
951 | two constants EXTA, EXTB ("External A" and "External B"). | |
952 | Many systems extend the list with much higher baud rates. | |
953 | .LP | |
c7094399 | 954 | The effect of a nonzero \fIduration\fP with |
60a90ecd MK |
955 | .BR tcsendbreak () |
956 | varies. | |
c13182ef | 957 | SunOS specifies a break of |
8b8d0001 | 958 | .I "duration\ *\ N" |
fea681da MK |
959 | seconds, where \fIN\fP is at least 0.25, and not more than 0.5. |
960 | Linux, AIX, DU, Tru64 send a break of | |
961 | .I duration | |
962 | milliseconds. | |
963 | FreeBSD and NetBSD and HP-UX and MacOS ignore the value of | |
964 | .IR duration . | |
1f409d5d | 965 | Under Solaris and UnixWare, |
e511ffb6 | 966 | .BR tcsendbreak () |
c7094399 | 967 | with nonzero |
fea681da MK |
968 | .I duration |
969 | behaves like | |
e511ffb6 | 970 | .BR tcdrain (). |
fea681da MK |
971 | .\" libc4 until 4.7.5, glibc for sysv: EINVAL for duration > 0. |
972 | .\" libc4.7.6, libc5, glibc for unix: duration in ms. | |
973 | .\" glibc for bsd: duration in us | |
974 | .\" glibc for sunos4: ignore duration | |
47297adb | 975 | .SH SEE ALSO |
fea681da | 976 | .BR stty (1), |
fe62e3de MK |
977 | .BR console_ioctl (4), |
978 | .BR tty_ioctl (4), | |
fea681da | 979 | .BR setserial (8) |