]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 2002 Walter Harms <walter.harms@informatik.uni-oldenburg.de> |
2 | .\" and Andries Brouwer <aeb@cwi.nl>. | |
2297bf0e | 3 | .\" |
38f20bb9 | 4 | .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE) |
b18188c5 | 5 | .\" Distributed under GPL |
38f20bb9 | 6 | .\" %%%LICENSE_END |
fea681da | 7 | .\" |
bffbb22f | 8 | .TH IOCTL_TTY 2 2020-06-09 "Linux" "Linux Programmer's Manual" |
fea681da | 9 | .SH NAME |
a78f6752 | 10 | ioctl_tty \- ioctls for terminals and serial lines |
fea681da | 11 | .SH SYNOPSIS |
0daa9e92 | 12 | .B "#include <termios.h>" |
68e4db0a | 13 | .PP |
c13182ef | 14 | .BI "int ioctl(int " fd ", int " cmd ", ...);" |
fea681da MK |
15 | .SH DESCRIPTION |
16 | The | |
0b80cf56 | 17 | .BR ioctl (2) |
fea681da | 18 | call for terminals and serial ports accepts many possible command arguments. |
c6fa0841 MK |
19 | Most require a third argument, of varying type, here called |
20 | .I argp | |
21 | or | |
22 | .IR arg . | |
dd3568a1 | 23 | .PP |
fea681da MK |
24 | Use of |
25 | .I ioctl | |
d603cc27 | 26 | makes for nonportable programs. |
c13182ef | 27 | Use the POSIX interface described in |
fea681da MK |
28 | .BR termios (3) |
29 | whenever possible. | |
73d8cece | 30 | .SS Get and set terminal attributes |
fea681da MK |
31 | .TP |
32 | .BI "TCGETS struct termios *" argp | |
33 | Equivalent to | |
34 | .IR "tcgetattr(fd, argp)" . | |
322522ea | 35 | .IP |
fea681da MK |
36 | Get the current serial port settings. |
37 | .TP | |
38 | .BI "TCSETS const struct termios *" argp | |
39 | Equivalent to | |
40 | .IR "tcsetattr(fd, TCSANOW, argp)" . | |
322522ea | 41 | .IP |
fea681da MK |
42 | Set the current serial port settings. |
43 | .TP | |
44 | .BI "TCSETSW const struct termios *" argp | |
45 | Equivalent to | |
46 | .IR "tcsetattr(fd, TCSADRAIN, argp)" . | |
322522ea | 47 | .IP |
fea681da MK |
48 | Allow the output buffer to drain, and |
49 | set the current serial port settings. | |
50 | .TP | |
51 | .BI "TCSETSF const struct termios *" argp | |
52 | Equivalent to | |
53 | .IR "tcsetattr(fd, TCSAFLUSH, argp)" . | |
322522ea | 54 | .IP |
fea681da MK |
55 | Allow the output buffer to drain, discard pending input, and |
56 | set the current serial port settings. | |
dd3568a1 | 57 | .PP |
097585ed MK |
58 | The following four ioctls are just like |
59 | .BR TCGETS , | |
60 | .BR TCSETS , | |
61 | .BR TCSETSW , | |
62 | .BR TCSETSF , | |
fea681da | 63 | except that they take a |
5049da5b | 64 | .I "struct termio\ *" |
fea681da | 65 | instead of a |
5049da5b | 66 | .IR "struct termios\ *" . |
52a5ae2b | 67 | .IP |
fea681da | 68 | .BI "TCGETA struct termio *" argp |
52a5ae2b | 69 | .IP |
fea681da | 70 | .BI "TCSETA const struct termio *" argp |
52a5ae2b | 71 | .IP |
fea681da | 72 | .BI "TCSETAW const struct termio *" argp |
52a5ae2b | 73 | .IP |
fea681da | 74 | .BI "TCSETAF const struct termio *" argp |
73d8cece | 75 | .SS Locking the termios structure |
4961e71d MK |
76 | The |
77 | .I termios | |
132249c4 | 78 | structure of a terminal can be locked. |
4961e71d MK |
79 | The lock is itself a |
80 | .I termios | |
c7094399 | 81 | structure, with nonzero bits or fields indicating a |
fea681da MK |
82 | locked value. |
83 | .TP | |
84 | .BI "TIOCGLCKTRMIOS struct termios *" argp | |
4961e71d MK |
85 | Gets the locking status of the |
86 | .I termios | |
87 | structure of the terminal. | |
fea681da MK |
88 | .TP |
89 | .BI "TIOCSLCKTRMIOS const struct termios *" argp | |
4961e71d MK |
90 | Sets the locking status of the |
91 | .I termios | |
92 | structure of the terminal. | |
cb476d88 | 93 | Only a process with the |
c0b75059 | 94 | .BR CAP_SYS_ADMIN |
cb476d88 | 95 | capability can do this. |
73d8cece | 96 | .SS Get and set window size |
fea681da MK |
97 | Window sizes are kept in the kernel, but not used by the kernel |
98 | (except in the case of virtual consoles, where the kernel will | |
99 | update the window size when the size of the virtual console changes, | |
75b94dc3 | 100 | for example, by loading a new font). |
efeece04 | 101 | .PP |
cba5091d MK |
102 | The following constants and structure are defined in |
103 | .IR <sys/ioctl.h> . | |
fea681da MK |
104 | .TP |
105 | .BI "TIOCGWINSZ struct winsize *" argp | |
106 | Get window size. | |
107 | .TP | |
108 | .BI "TIOCSWINSZ const struct winsize *" argp | |
109 | Set window size. | |
dd3568a1 | 110 | .PP |
fea681da | 111 | The struct used by these ioctls is defined as |
efeece04 | 112 | .PP |
3f89ebc0 | 113 | .in +4n |
b76974c1 | 114 | .EX |
fea681da | 115 | struct winsize { |
cf0a9ace MK |
116 | unsigned short ws_row; |
117 | unsigned short ws_col; | |
118 | unsigned short ws_xpixel; /* unused */ | |
119 | unsigned short ws_ypixel; /* unused */ | |
fea681da | 120 | }; |
b76974c1 | 121 | .EE |
3f89ebc0 | 122 | .in |
efeece04 | 123 | .PP |
8bd58774 MK |
124 | When the window size changes, a |
125 | .B SIGWINCH | |
126 | signal is sent to the | |
fea681da | 127 | foreground process group. |
73d8cece | 128 | .SS Sending a break |
fea681da MK |
129 | .TP |
130 | .BI "TCSBRK int " arg | |
131 | Equivalent to | |
132 | .IR "tcsendbreak(fd, arg)" . | |
322522ea | 133 | .IP |
fea681da MK |
134 | If the terminal is using asynchronous serial data transmission, and |
135 | .I arg | |
136 | is zero, then send a break (a stream of zero bits) for between | |
c13182ef MK |
137 | 0.25 and 0.5 seconds. |
138 | If the terminal is not using asynchronous | |
fea681da MK |
139 | serial data transmission, then either a break is sent, or the function |
140 | returns without doing anything. | |
141 | When | |
142 | .I arg | |
c7094399 | 143 | is nonzero, nobody knows what will happen. |
efeece04 | 144 | .IP |
72cedc06 | 145 | (SVr4, UnixWare, Solaris, Linux treat |
fea681da | 146 | .I "tcsendbreak(fd,arg)" |
c7094399 | 147 | with nonzero |
fea681da MK |
148 | .I arg |
149 | like | |
150 | .IR "tcdrain(fd)" . | |
151 | SunOS treats | |
152 | .I arg | |
153 | as a multiplier, and sends a stream of bits | |
154 | .I arg | |
155 | times as long as done for zero | |
156 | .IR arg . | |
72cedc06 | 157 | DG/UX and AIX treat |
fea681da | 158 | .I arg |
c7094399 | 159 | (when nonzero) as a time interval measured in milliseconds. |
fea681da MK |
160 | HP-UX ignores |
161 | .IR arg .) | |
162 | .TP | |
163 | .BI "TCSBRKP int " arg | |
097585ed MK |
164 | So-called "POSIX version" of |
165 | .BR TCSBRK . | |
c7094399 | 166 | It treats nonzero |
fea681da | 167 | .I arg |
8842f534 | 168 | as a time interval measured in deciseconds, and does nothing |
fea681da MK |
169 | when the driver does not support breaks. |
170 | .TP | |
0daa9e92 | 171 | .B "TIOCSBRK void" |
fea681da MK |
172 | Turn break on, that is, start sending zero bits. |
173 | .TP | |
0daa9e92 | 174 | .B "TIOCCBRK void" |
fea681da | 175 | Turn break off, that is, stop sending zero bits. |
73d8cece | 176 | .SS Software flow control |
fea681da MK |
177 | .TP |
178 | .BI "TCXONC int " arg | |
179 | Equivalent to | |
180 | .IR "tcflow(fd, arg)" . | |
322522ea | 181 | .IP |
fea681da MK |
182 | See |
183 | .BR tcflow (3) | |
097585ed MK |
184 | for the argument values |
185 | .BR TCOOFF , | |
186 | .BR TCOON , | |
187 | .BR TCIOFF , | |
188 | .BR TCION . | |
73d8cece | 189 | .SS Buffer count and flushing |
fea681da MK |
190 | .TP |
191 | .BI "FIONREAD int *" argp | |
192 | Get the number of bytes in the input buffer. | |
193 | .TP | |
194 | .BI "TIOCINQ int *" argp | |
097585ed MK |
195 | Same as |
196 | .BR FIONREAD . | |
fea681da MK |
197 | .TP |
198 | .BI "TIOCOUTQ int *" argp | |
199 | Get the number of bytes in the output buffer. | |
200 | .TP | |
201 | .BI "TCFLSH int " arg | |
202 | Equivalent to | |
203 | .IR "tcflush(fd, arg)" . | |
322522ea | 204 | .IP |
fea681da MK |
205 | See |
206 | .BR tcflush (3) | |
097585ed MK |
207 | for the argument values |
208 | .BR TCIFLUSH , | |
209 | .BR TCOFLUSH , | |
210 | .BR TCIOFLUSH . | |
73d8cece | 211 | .SS Faking input |
fea681da MK |
212 | .TP |
213 | .BI "TIOCSTI const char *" argp | |
214 | Insert the given byte in the input queue. | |
73d8cece | 215 | .SS Redirecting console output |
fea681da | 216 | .TP |
0daa9e92 | 217 | .B "TIOCCONS void" |
fea681da MK |
218 | Redirect output that would have gone to |
219 | .I /dev/console | |
220 | or | |
221 | .I /dev/tty0 | |
132249c4 | 222 | to the given terminal. |
b218b023 | 223 | If that was a pseudoterminal master, send it to the slave. |
b5fa38a3 MK |
224 | In Linux before version 2.6.10, |
225 | anybody can do this as long as the output was not redirected yet; | |
cb476d88 | 226 | since version 2.6.10, only a process with the |
b5fa38a3 | 227 | .BR CAP_SYS_ADMIN |
cb476d88 | 228 | capability may do this. |
c4316bb5 | 229 | If output was redirected already, then |
097585ed MK |
230 | .B EBUSY |
231 | is returned, | |
b5fa38a3 | 232 | but redirection can be stopped by using this ioctl with |
fea681da MK |
233 | .I fd |
234 | pointing at | |
235 | .I /dev/console | |
236 | or | |
237 | .IR /dev/tty0 . | |
73d8cece | 238 | .SS Controlling terminal |
fea681da MK |
239 | .TP |
240 | .BI "TIOCSCTTY int " arg | |
132249c4 | 241 | Make the given terminal the controlling terminal of the calling process. |
a1ffe9f5 | 242 | The calling process must be a session leader and not have a |
132249c4 | 243 | controlling terminal already. |
9ab0de3c MK |
244 | For this case, |
245 | .I arg | |
246 | should be specified as zero. | |
efeece04 | 247 | .IP |
132249c4 | 248 | If this terminal is already the controlling terminal |
5cc100b9 | 249 | of a different session group, then the ioctl fails with |
097585ed | 250 | .BR EPERM , |
cb476d88 | 251 | unless the caller has the |
c0b75059 | 252 | .BR CAP_SYS_ADMIN |
cb476d88 | 253 | capability and |
fea681da | 254 | .I arg |
132249c4 MK |
255 | equals 1, in which case the terminal is stolen, and all processes that had |
256 | it as controlling terminal lose it. | |
fea681da | 257 | .TP |
17434a0d | 258 | .B "TIOCNOTTY void" |
132249c4 MK |
259 | If the given terminal was the controlling terminal of the calling process, |
260 | give up this controlling terminal. | |
c13182ef | 261 | If the process was session leader, |
8bd58774 MK |
262 | then send |
263 | .B SIGHUP | |
264 | and | |
265 | .B SIGCONT | |
266 | to the foreground process group | |
132249c4 | 267 | and all processes in the current session lose their controlling terminal. |
73d8cece | 268 | .SS Process group and session ID |
fea681da MK |
269 | .TP |
270 | .BI "TIOCGPGRP pid_t *" argp | |
271 | When successful, equivalent to | |
272 | .IR "*argp = tcgetpgrp(fd)" . | |
322522ea | 273 | .IP |
132249c4 | 274 | Get the process group ID of the foreground process group on this terminal. |
fea681da MK |
275 | .TP |
276 | .BI "TIOCSPGRP const pid_t *" argp | |
277 | Equivalent to | |
278 | .IR "tcsetpgrp(fd, *argp)" . | |
322522ea | 279 | .IP |
132249c4 | 280 | Set the foreground process group ID of this terminal. |
fea681da MK |
281 | .TP |
282 | .BI "TIOCGSID pid_t *" argp | |
132249c4 | 283 | Get the session ID of the given terminal. |
ad94e27c | 284 | This fails with the error |
097585ed | 285 | .B ENOTTY |
a23d8efa | 286 | if the terminal is not a master pseudoterminal |
132249c4 | 287 | and not our controlling terminal. |
c13182ef | 288 | Strange. |
73d8cece | 289 | .SS Exclusive mode |
fea681da | 290 | .TP |
0daa9e92 | 291 | .B "TIOCEXCL void" |
132249c4 | 292 | Put the terminal into exclusive mode. |
fea681da MK |
293 | No further |
294 | .BR open (2) | |
295 | operations on the terminal are permitted. | |
ad94e27c | 296 | (They fail with |
097585ed | 297 | .BR EBUSY , |
cb476d88 | 298 | except for a process with the |
c0b75059 MK |
299 | .BR CAP_SYS_ADMIN |
300 | capability.) | |
fea681da | 301 | .TP |
8b17edbe | 302 | .BI "TIOCGEXCL int *" argp |
164b4016 | 303 | (since Linux 3.8) |
8b17edbe MK |
304 | If the terminal is currently in exclusive mode, |
305 | place a nonzero value in the location pointed to by | |
306 | .IR argp ; | |
307 | otherwise, place zero in | |
164b4016 | 308 | .IR *argp . |
8b17edbe | 309 | .TP |
0daa9e92 | 310 | .B "TIOCNXCL void" |
fea681da | 311 | Disable exclusive mode. |
73d8cece | 312 | .SS Line discipline |
fea681da MK |
313 | .TP |
314 | .BI "TIOCGETD int *" argp | |
132249c4 | 315 | Get the line discipline of the terminal. |
fea681da MK |
316 | .TP |
317 | .BI "TIOCSETD const int *" argp | |
132249c4 | 318 | Set the line discipline of the terminal. |
73d8cece | 319 | .SS Pseudoterminal ioctls |
fea681da MK |
320 | .TP |
321 | .BI "TIOCPKT const int *" argp | |
322 | Enable (when | |
323 | .RI * argp | |
c7094399 | 324 | is nonzero) or disable packet mode. |
b218b023 | 325 | Can be applied to the master side of a pseudoterminal only (and will return |
097585ed MK |
326 | .B ENOTTY |
327 | otherwise). | |
c13182ef | 328 | In packet mode, each subsequent |
fea681da | 329 | .BR read (2) |
c7094399 | 330 | will return a packet that either contains a single nonzero control byte, |
cc1a0b7e | 331 | or has a single byte containing zero (\(aq\e0\(aq) followed by data |
b218b023 | 332 | written on the slave side of the pseudoterminal. |
097585ed MK |
333 | If the first byte is not |
334 | .B TIOCPKT_DATA | |
335 | (0), it is an OR of one | |
fea681da | 336 | or more of the following bits: |
efeece04 | 337 | .IP |
d6780634 MK |
338 | .TS |
339 | lb l. | |
340 | TIOCPKT_FLUSHREAD The read queue for the terminal is flushed. | |
341 | TIOCPKT_FLUSHWRITE The write queue for the terminal is flushed. | |
342 | TIOCPKT_STOP Output to the terminal is stopped. | |
343 | TIOCPKT_START Output to the terminal is restarted. | |
344 | TIOCPKT_DOSTOP The start and stop characters are \fB\(haS\fP/\fB\(haQ\fP. | |
345 | TIOCPKT_NOSTOP The start and stop characters are not \fB\(haS\fP/\fB\(haQ\fP. | |
346 | .TE | |
efeece04 | 347 | .IP |
c4316bb5 | 348 | While packet mode is in use, the presence |
fea681da MK |
349 | of control status information to be read |
350 | from the master side may be detected by a | |
351 | .BR select (2) | |
3352f579 MK |
352 | for exceptional conditions or a |
353 | .BR poll (2) | |
354 | for the | |
c4316bb5 | 355 | .B POLLPRI |
3352f579 | 356 | event. |
efeece04 | 357 | .IP |
fea681da MK |
358 | This mode is used by |
359 | .BR rlogin (1) | |
360 | and | |
361 | .BR rlogind (8) | |
f81fb444 | 362 | to implement a remote-echoed, |
9ca13180 | 363 | locally \fB\(haS\fP/\fB\(haQ\fP flow-controlled remote login. |
a3bee85c | 364 | .TP |
118c56a8 | 365 | .BI "TIOCGPKT const int *" argp |
164b4016 | 366 | (since Linux 3.8) |
a3bee85c | 367 | Return the current packet mode setting in the integer pointed to by |
164b4016 | 368 | .IR argp . |
bd020450 MK |
369 | .TP |
370 | .BI "TIOCSPTLCK int *" argp | |
371 | Set (if | |
372 | .IR *argp | |
373 | is nonzero) or remove (if | |
374 | .IR *argp | |
7b672080 | 375 | is zero) the lock on the pseudoterminal slave device. |
bd020450 MK |
376 | (See also |
377 | .BR unlockpt (3).) | |
e757b911 MK |
378 | .TP |
379 | .BI "TIOCGPTLCK int *" argp | |
164b4016 | 380 | (since Linux 3.8) |
e757b911 MK |
381 | Place the current lock state of the pseudoterminal slave device |
382 | in the location pointed to by | |
164b4016 | 383 | .IR argp . |
0ec74af9 AS |
384 | .TP |
385 | .BI "TIOCGPTPEER int " flags | |
91e34595 MK |
386 | .\" commit 54ebbfb1603415d9953c150535850d30609ef077 |
387 | (since Linux 4.13) | |
388 | Given a file descriptor in | |
389 | .I fd | |
390 | that refers to a pseudoterminal master, | |
391 | open (with the given | |
0ec74af9 | 392 | .BR open (2)-style |
91e34595 MK |
393 | .IR flags ) |
394 | and return a new file descriptor that refers to the peer | |
395 | pseudoterminal slave device. | |
396 | This operation can be performed | |
397 | regardless of whether the pathname of the slave device | |
5115e06c | 398 | is accessible through the calling process's mount namespace. |
efeece04 | 399 | .IP |
0ec74af9 | 400 | Security-conscious programs interacting with namespaces may wish to use this |
91e34595 | 401 | operation rather than |
0ec74af9 | 402 | .BR open (2) |
91e34595 | 403 | with the pathname returned by |
0ec74af9 | 404 | .BR ptsname (3), |
91e34595 | 405 | and similar library functions that have insecure APIs. |
d754b76d MK |
406 | (For example, confusion can occur in some cases using |
407 | .BR ptsname (3) | |
408 | with a pathname where a devpts filesystem | |
409 | has been mounted in a different mount namespace.) | |
e1215bb9 | 410 | .PP |
097585ed MK |
411 | The BSD ioctls |
412 | .BR TIOCSTOP , | |
413 | .BR TIOCSTART , | |
414 | .BR TIOCUCNTL , | |
0daa9e92 | 415 | .B TIOCREMOTE |
fea681da | 416 | have not been implemented under Linux. |
73d8cece | 417 | .SS Modem control |
fea681da MK |
418 | .TP |
419 | .BI "TIOCMGET int *" argp | |
2096c4f3 | 420 | Get the status of modem bits. |
fea681da MK |
421 | .TP |
422 | .BI "TIOCMSET const int *" argp | |
2096c4f3 | 423 | Set the status of modem bits. |
fea681da MK |
424 | .TP |
425 | .BI "TIOCMBIC const int *" argp | |
2096c4f3 | 426 | Clear the indicated modem bits. |
fea681da MK |
427 | .TP |
428 | .BI "TIOCMBIS const int *" argp | |
2096c4f3 | 429 | Set the indicated modem bits. |
dd3568a1 | 430 | .PP |
d398da7b | 431 | The following bits are used by the above ioctls: |
efeece04 | 432 | .PP |
d6780634 MK |
433 | .TS |
434 | lb l. | |
435 | TIOCM_LE DSR (data set ready/line enable) | |
436 | TIOCM_DTR DTR (data terminal ready) | |
437 | TIOCM_RTS RTS (request to send) | |
438 | TIOCM_ST Secondary TXD (transmit) | |
439 | TIOCM_SR Secondary RXD (receive) | |
440 | TIOCM_CTS CTS (clear to send) | |
441 | TIOCM_CAR DCD (data carrier detect) | |
442 | TIOCM_CD see TIOCM_CAR | |
443 | TIOCM_RNG RNG (ring) | |
444 | TIOCM_RI see TIOCM_RNG | |
445 | TIOCM_DSR DSR (data set ready) | |
446 | .TE | |
1dcf15dd | 447 | .TP |
41556382 MK |
448 | .BI "TIOCMIWAIT int " arg |
449 | Wait for any of the 4 modem bits (DCD, RI, DSR, CTS) to change. | |
450 | The bits of interest are specified as a bit mask in | |
451 | .IR arg , | |
452 | by ORing together any of the bit values, | |
453 | .BR TIOCM_RNG , | |
454 | .BR TIOCM_DSR , | |
455 | .BR TIOCM_CD , | |
456 | and | |
457 | .BR TIOCM_CTS . | |
458 | The caller should use | |
459 | .B TIOCGICOUNT | |
460 | to see which bit has changed. | |
461 | .TP | |
1dcf15dd | 462 | .BI "TIOCGICOUNT struct serial_icounter_struct *" argp |
452f300b | 463 | Get counts of input serial line interrupts (DCD, RI, DSR, CTS). |
5ffdc2fd | 464 | The counts are written to the |
452f300b MK |
465 | .I serial_icounter_struct |
466 | structure pointed to by | |
467 | .IR argp . | |
efeece04 | 468 | .IP |
452f300b MK |
469 | Note: both 1->0 and 0->1 transitions are counted, except for |
470 | RI, where only 0->1 transitions are counted. | |
73d8cece | 471 | .SS Marking a line as local |
fea681da MK |
472 | .TP |
473 | .BI "TIOCGSOFTCAR int *" argp | |
474 | ("Get software carrier flag") | |
475 | Get the status of the CLOCAL flag in the c_cflag field of the | |
4961e71d MK |
476 | .I termios |
477 | structure. | |
fea681da MK |
478 | .TP |
479 | .BI "TIOCSSOFTCAR const int *" argp | |
480 | ("Set software carrier flag") | |
4961e71d MK |
481 | Set the CLOCAL flag in the |
482 | .I termios | |
483 | structure when | |
fea681da | 484 | .RI * argp |
c7094399 | 485 | is nonzero, and clear it otherwise. |
dd3568a1 | 486 | .PP |
097585ed MK |
487 | If the |
488 | .B CLOCAL | |
489 | flag for a line is off, the hardware carrier detect (DCD) | |
fea681da MK |
490 | signal is significant, and an |
491 | .BR open (2) | |
132249c4 | 492 | of the corresponding terminal will block until DCD is asserted, |
097585ed MK |
493 | unless the |
494 | .B O_NONBLOCK | |
495 | flag is given. | |
496 | If | |
497 | .B CLOCAL | |
498 | is set, the line behaves as if DCD is always asserted. | |
fea681da MK |
499 | The software carrier flag is usually turned on for local devices, |
500 | and is off for lines with modems. | |
73d8cece | 501 | .SS Linux-specific |
097585ed MK |
502 | For the |
503 | .B TIOCLINUX | |
504 | ioctl, see | |
d49a2220 | 505 | .BR ioctl_console (2). |
73d8cece | 506 | .SS Kernel debugging |
0daa9e92 | 507 | .B "#include <linux/tty.h>" |
fea681da MK |
508 | .TP |
509 | .BI "TIOCTTYGSTRUCT struct tty_struct *" argp | |
f88233dd MK |
510 | Get the |
511 | .I tty_struct | |
512 | corresponding to | |
fea681da | 513 | .IR fd . |
0e61ffa7 MK |
514 | This command was removed in Linux 2.5.67. |
515 | .\" commit b3506a09d15dc5aee6d4bb88d759b157016e1864 | |
516 | .\" Author: Andries E. Brouwer <andries.brouwer@cwi.nl> | |
517 | .\" Date: Tue Apr 1 04:42:46 2003 -0800 | |
518 | .\" | |
519 | .\" [PATCH] kill TIOCTTYGSTRUCT | |
520 | .\" | |
521 | .\" Only used for (dubious) debugging purposes, and exposes | |
522 | .\" internal kernel state. | |
c13182ef | 523 | .\" |
d282bb24 | 524 | .\" .SS Serial info |
fea681da | 525 | .\" .BR "#include <linux/serial.h>" |
ba39b288 | 526 | .\" .PP |
fea681da MK |
527 | .\" .TP |
528 | .\" .BI "TIOCGSERIAL struct serial_struct *" argp | |
529 | .\" Get serial info. | |
530 | .\" .TP | |
531 | .\" .BI "TIOCSSERIAL const struct serial_struct *" argp | |
532 | .\" Set serial info. | |
47297adb | 533 | .SH RETURN VALUE |
fea681da | 534 | The |
0b80cf56 | 535 | .BR ioctl (2) |
c13182ef | 536 | system call returns 0 on success. |
dec985f9 | 537 | On error, it returns \-1 and sets |
fea681da MK |
538 | .I errno |
539 | appropriately. | |
fea681da MK |
540 | .SH ERRORS |
541 | .TP | |
fea681da MK |
542 | .B EINVAL |
543 | Invalid command parameter. | |
544 | .TP | |
eab64696 MK |
545 | .B ENOIOCTLCMD |
546 | Unknown command. | |
fea681da MK |
547 | .TP |
548 | .B ENOTTY | |
549 | Inappropriate | |
550 | .IR fd . | |
eab64696 MK |
551 | .TP |
552 | .B EPERM | |
553 | Insufficient permission. | |
a14af333 | 554 | .SH EXAMPLES |
fea681da | 555 | Check the condition of DTR on the serial port. |
efeece04 | 556 | .PP |
b76974c1 | 557 | .EX |
fea681da MK |
558 | #include <termios.h> |
559 | #include <fcntl.h> | |
560 | #include <sys/ioctl.h> | |
561 | ||
cf0a9ace | 562 | int |
c13182ef | 563 | main(void) |
cf0a9ace | 564 | { |
fea681da MK |
565 | int fd, serial; |
566 | ||
567 | fd = open("/dev/ttyS0", O_RDONLY); | |
568 | ioctl(fd, TIOCMGET, &serial); | |
569 | if (serial & TIOCM_DTR) | |
fea681da | 570 | puts("TIOCM_DTR is set"); |
e3f16cf7 MK |
571 | else |
572 | puts("TIOCM_DTR is not set"); | |
fea681da MK |
573 | close(fd); |
574 | } | |
b76974c1 | 575 | .EE |
47297adb | 576 | .SH SEE ALSO |
c1a68b5e | 577 | .BR ldattach (1), |
fea681da | 578 | .BR ioctl (2), |
d49a2220 | 579 | .BR ioctl_console (2), |
fea681da | 580 | .BR termios (3), |
88ab292b | 581 | .BR pty (7) |
25a46448 | 582 | .\" |
fea681da MK |
583 | .\" FIONBIO const int * |
584 | .\" FIONCLEX void | |
585 | .\" FIOCLEX void | |
586 | .\" FIOASYNC const int * | |
587 | .\" from serial.c: | |
588 | .\" TIOCSERCONFIG void | |
589 | .\" TIOCSERGWILD int * | |
590 | .\" TIOCSERSWILD const int * | |
591 | .\" TIOCSERGSTRUCT struct async_struct * | |
592 | .\" TIOCSERGETLSR int * | |
593 | .\" TIOCSERGETMULTI struct serial_multiport_struct * | |
594 | .\" TIOCSERSETMULTI const struct serial_multiport_struct * | |
595 | .\" TIOCGSERIAL, TIOCSSERIAL (see above) |