Thu Apr 28 12:15:35 2011 UTC ()
New sentence, new line.


(wiz)
diff -r1.26 -r1.27 src/share/man/man4/tty.4

cvs diff -r1.26 -r1.27 src/share/man/man4/tty.4 (expand / switch to unified diff)

--- src/share/man/man4/tty.4 2010/03/22 18:58:31 1.26
+++ src/share/man/man4/tty.4 2011/04/28 12:15:35 1.27
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: tty.4,v 1.26 2010/03/22 18:58:31 joerg Exp $ 1.\" $NetBSD: tty.4,v 1.27 2011/04/28 12:15:35 wiz Exp $
2.\" 2.\"
3.\" Copyright (c) 1991, 1992, 1993 3.\" Copyright (c) 1991, 1992, 1993
4.\" The Regents of the University of California. All rights reserved. 4.\" The Regents of the University of California. All rights reserved.
5.\" 5.\"
6.\" Redistribution and use in source and binary forms, with or without 6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions 7.\" modification, are permitted provided that the following conditions
8.\" are met: 8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright 9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer. 10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the 12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution. 13.\" documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors 14.\" 3. Neither the name of the University nor the names of its contributors
@@ -50,128 +50,132 @@ and @@ -50,128 +50,132 @@ and
50.Pa /dev/dty03 ) . 50.Pa /dev/dty03 ) .
51.Pp 51.Pp
52The 52The
53.Pa /dev/ttyXX 53.Pa /dev/ttyXX
54special file is used for dial-in modems and terminals. 54special file is used for dial-in modems and terminals.
55When a user logs into 55When a user logs into
56the system on one of these hardware terminal ports, the system has already 56the system on one of these hardware terminal ports, the system has already
57opened the associated device and prepared the line for normal interactive 57opened the associated device and prepared the line for normal interactive
58use (see 58use (see
59.Xr getty 8 ) . 59.Xr getty 8 ) .
60.Pp 60.Pp
61The 61The
62.Pa /dev/dtyXX 62.Pa /dev/dtyXX
63special file is a SunOS-compatible dial-out device. Unlike 63special file is a SunOS-compatible dial-out device.
64the dial-in device, opening the dial-out device never blocks. If the 64Unlike the dial-in device, opening the dial-out device never blocks.
65corresponding dial-in device is already opened (not blocked in the open waiting 65If the corresponding dial-in device is already opened (not blocked
66for carrier), then the dial-out open will fail immediately; otherwise it will 66in the open waiting for carrier), then the dial-out open will fail
67succeed immediately. While the dial-out device is open, the dial-in device may 67immediately; otherwise it will succeed immediately.
68not be opened. If the dial-in open is blocking, it will wait until the dial-out 68While the dial-out device is open, the dial-in device may not be opened.
 69If the dial-in open is blocking, it will wait until the dial-out
69device is closed (and carrier is detected); otherwise it will fail immediately. 70device is closed (and carrier is detected); otherwise it will fail immediately.
70.Pp 71.Pp
71There is also a special case of a terminal file that connects not to 72There is also a special case of a terminal file that connects not to
72a hardware terminal port, but to another program on the other side. 73a hardware terminal port, but to another program on the other side.
73These special terminal devices are called 74These special terminal devices are called
74.Em ptys 75.Em ptys
75(pseudo terminals) 76(pseudo terminals)
76and provide the mechanism necessary to give users the same interface to the 77and provide the mechanism necessary to give users the same interface to the
77system when logging in over a network (using 78system when logging in over a network (using
78.Xr rlogin 1 , 79.Xr rlogin 1 ,
79or 80or
80.Xr telnet 1 81.Xr telnet 1
81for example.) Even in these cases the details of how the terminal 82for example.) Even in these cases the details of how the terminal
82file was opened and set up is already handled by special software 83file was opened and set up is already handled by special software
83in the system. 84in the system.
84Thus, users do not normally need to worry about the details of 85Thus, users do not normally need to worry about the details of
85how these lines are opened or used. Also, these lines are often used 86how these lines are opened or used.
86for dialing out of a system (through an out-calling modem), but again 87Also, these lines are often used for dialing out of a system (through
87the system provides programs that hide the details of accessing 88an out-calling modem), but again the system provides programs that
88these terminal special files (see 89hide the details of accessing these terminal special files (see
89.Xr tip 1 ) . 90.Xr tip 1 ) .
90.Pp 91.Pp
91When an interactive user logs in, the system prepares the line to 92When an interactive user logs in, the system prepares the line to
92behave in a certain way (called a 93behave in a certain way (called a
93.Em line discipline ) , 94.Em line discipline ) ,
94the particular details of which is described in 95the particular details of which is described in
95.Xr stty 1 96.Xr stty 1
96at the command level, and in 97at the command level, and in
97.Xr termios 4 98.Xr termios 4
98at the programming level. A user may be concerned with changing 99at the programming level.
99settings associated with his particular login terminal and should refer 100A user may be concerned with changing settings associated with his
100to the preceding man pages for the common cases. The remainder of 101particular login terminal and should refer to the preceding man
101this man page is concerned 102pages for the common cases.
 103The remainder of this man page is concerned
102with describing details of using and controlling terminal devices 104with describing details of using and controlling terminal devices
103at a low level, such as that possibly required by a program wishing 105at a low level, such as that possibly required by a program wishing
104to provide features similar to those provided by the system. 106to provide features similar to those provided by the system.
105.Ss Line disciplines 107.Ss Line disciplines
106A terminal file is used like any other file in the system in that 108A terminal file is used like any other file in the system in that
107it can be opened, read, and written to using standard system 109it can be opened, read, and written to using standard system calls.
108calls. For each existing terminal file, there is a software processing module 110For each existing terminal file, there is a software processing module
109called a 111called a
110.Em line discipline 112.Em line discipline
111associated with it. The 113associated with it.
 114The
112.Em line discipline 115.Em line discipline
113essentially glues the low level device driver code with the high 116essentially glues the low level device driver code with the high
114level generic interface routines (such as 117level generic interface routines (such as
115.Xr read 2 118.Xr read 2
116and 119and
117.Xr write 2 ) , 120.Xr write 2 ) ,
118and is responsible for implementing the semantics associated 121and is responsible for implementing the semantics associated
119with the device. When a terminal file is first opened by a program, 122with the device.
120the default 123When a terminal file is first opened by a program, the default
121.Em line discipline 124.Em line discipline
122called the 125called the
123.Dv termios 126.Dv termios
124line discipline is associated with the file. This is the primary 127line discipline is associated with the file.
125line discipline that is used in most cases and provides the semantics 128This is the primary line discipline that is used in most cases and
126that users normally associate with a terminal. When the 129provides the semantics that users normally associate with a terminal.
 130When the
127.Dv termios 131.Dv termios
128line discipline is in effect, the terminal file behaves and is 132line discipline is in effect, the terminal file behaves and is
129operated according to the rules described in 133operated according to the rules described in
130.Xr termios 4 . 134.Xr termios 4 .
131Please refer to that man page for a full description of the terminal 135Please refer to that man page for a full description of the terminal
132semantics. 136semantics.
133The operations described here 137The operations described here
134generally represent features common 138generally represent features common
135across all 139across all
136.Em line disciplines , 140.Em line disciplines ,
137however some of these calls may not 141however some of these calls may not
138make sense in conjunction with a line discipline other than 142make sense in conjunction with a line discipline other than
139.Dv termios , 143.Dv termios ,
140and some may not be supported by the underlying 144and some may not be supported by the underlying
141hardware (or lack thereof, as in the case of ptys). 145hardware (or lack thereof, as in the case of ptys).
142.Ss Terminal File Operations 146.Ss Terminal File Operations
143All of the following operations are invoked using the 147All of the following operations are invoked using the
144.Xr ioctl 2 148.Xr ioctl 2
145system call. Refer to that man page for a description of 149system call.
146the 150Refer to that man page for a description of the
147.Em request 151.Em request
148and 152and
149.Em argp 153.Em argp
150parameters. 154parameters.
151In addition to the ioctl 155In addition to the ioctl
152.Em requests 156.Em requests
153defined here, the specific line discipline 157defined here, the specific line discipline
154in effect will define other 158in effect will define other
155.Em requests 159.Em requests
156specific to it (actually 160specific to it (actually
157.Xr termios 4 161.Xr termios 4
158defines them as function calls, not ioctl 162defines them as function calls, not ioctl
159.Em requests . ) 163.Em requests . )
160The following section lists the available ioctl requests. The 164The following section lists the available ioctl requests.
161name of the request, a description of its purpose, and the typed 165The name of the request, a description of its purpose, and the typed
162.Em argp 166.Em argp
163parameter (if any) 167parameter (if any) are listed.
164are listed. For example, the first entry says 168For example, the first entry says
165.Pp 169.Pp
166.D1 Em TIOCSLINED char name[32] 170.D1 Em TIOCSLINED char name[32]
167.Pp 171.Pp
168and would be called on the terminal associated with 172and would be called on the terminal associated with
169file descriptor zero by the following code fragment: 173file descriptor zero by the following code fragment:
170.Bd -literal 174.Bd -literal
171 ioctl(0, TIOCSLINED, "termios"); 175 ioctl(0, TIOCSLINED, "termios");
172.Ed 176.Ed
173.Ss Terminal File Request Descriptions 177.Ss Terminal File Request Descriptions
174.Bl -tag -width TIOCGWINSZ 178.Bl -tag -width TIOCGWINSZ
175.It Dv TIOCSLINED Fa char name[32] 179.It Dv TIOCSLINED Fa char name[32]
176Change to the new line discipline called 180Change to the new line discipline called
177.Fa name . 181.Fa name .
@@ -225,122 +229,128 @@ option. @@ -225,122 +229,128 @@ option.
225.It Dv TIOCSETAF Fa struct termios *term 229.It Dv TIOCSETAF Fa struct termios *term
226First wait for any output to complete, clear any pending input, 230First wait for any output to complete, clear any pending input,
227then set the termios state associated with the device. 231then set the termios state associated with the device.
228This is the underlying call that implements the 232This is the underlying call that implements the
229.Xr tcsetattr 3 233.Xr tcsetattr 3
230call with the 234call with the
231.Dv TCSAFLUSH 235.Dv TCSAFLUSH
232option. 236option.
233.It Dv TIOCOUTQ Fa int *num 237.It Dv TIOCOUTQ Fa int *num
234Place the current number of characters in the output queue in the 238Place the current number of characters in the output queue in the
235integer pointed to by 239integer pointed to by
236.Fa num . 240.Fa num .
237.It Dv TIOCSTI Fa char *cp 241.It Dv TIOCSTI Fa char *cp
238Simulate typed input. Pretend as if the terminal received the 242Simulate typed input.
239character pointed to by 243Pretend as if the terminal received the character pointed to by
240.Fa cp . 244.Fa cp .
241.It Dv TIOCNOTTY Fa void 245.It Dv TIOCNOTTY Fa void
242This call is obsolete but left for compatibility. In the past, when 246This call is obsolete but left for compatibility.
243a process that didn't have a controlling terminal (see 247In the past, when a process that didn't have a controlling terminal
 248(see
244.Em The Controlling Terminal 249.Em The Controlling Terminal
245in 250in
246.Xr termios 4 ) 251.Xr termios 4 )
247first opened a terminal device, it acquired that terminal as its 252first opened a terminal device, it acquired that terminal as its
248controlling terminal. For some programs this was a hazard as they 253controlling terminal.
249didn't want a controlling terminal in the first place, and this 254For some programs this was a hazard as they didn't want a controlling
250provided a mechanism to disassociate the controlling terminal from 255terminal in the first place, and this provided a mechanism to
251the calling process. It 256disassociate the controlling terminal from the calling process.
 257It
252.Em must 258.Em must
253be called by opening the file 259be called by opening the file
254.Pa /dev/tty 260.Pa /dev/tty
255and calling 261and calling
256.Dv TIOCNOTTY 262.Dv TIOCNOTTY
257on that file descriptor. 263on that file descriptor.
258.Pp 264.Pp
259The current system does not allocate a controlling terminal to 265The current system does not allocate a controlling terminal to
260a process on an 266a process on an
261.Fn open 267.Fn open
262call: there is a specific ioctl called 268call: there is a specific ioctl called
263.Dv TIOCSCTTY 269.Dv TIOCSCTTY
264to make a terminal the controlling 270to make a terminal the controlling
265terminal. 271terminal.
266In addition, a program can 272In addition, a program can
267.Fn fork 273.Fn fork
268and call the 274and call the
269.Fn setsid 275.Fn setsid
270system call which will place the process into its own session - which 276system call which will place the process into its own session - which
271has the effect of disassociating it from the controlling terminal. This 277has the effect of disassociating it from the controlling terminal.
272is the new and preferred method for programs to lose their controlling 278This is the new and preferred method for programs to lose their
273terminal. 279controlling terminal.
274.It Dv TIOCSTOP Fa void 280.It Dv TIOCSTOP Fa void
275Stop output on the terminal (like typing ^S at the keyboard). 281Stop output on the terminal (like typing ^S at the keyboard).
276.It Dv TIOCSTART Fa void 282.It Dv TIOCSTART Fa void
277Start output on the terminal (like typing ^Q at the keyboard). 283Start output on the terminal (like typing ^Q at the keyboard).
278.It Dv TIOCSCTTY Fa void 284.It Dv TIOCSCTTY Fa void
279Make the terminal the controlling terminal for the process (the process 285Make the terminal the controlling terminal for the process (the process
280must not currently have a controlling terminal). 286must not currently have a controlling terminal).
281.It Dv TIOCDRAIN Fa void 287.It Dv TIOCDRAIN Fa void
282Wait until all output is drained. 288Wait until all output is drained.
283.It Dv TIOCEXCL Fa void 289.It Dv TIOCEXCL Fa void
284Set exclusive use on the terminal. No further opens are permitted 290Set exclusive use on the terminal.
285except by root. Of course, this means that programs that are run by 291No further opens are permitted except by root.
286root (or setuid) will not obey the exclusive setting - which limits 292Of course, this means that programs that are run by root (or setuid)
287the usefulness of this feature. 293will not obey the exclusive setting - which limits the usefulness
 294of this feature.
288.It Dv TIOCNXCL Fa void 295.It Dv TIOCNXCL Fa void
289Clear exclusive use of the terminal. Further opens are permitted. 296Clear exclusive use of the terminal.
 297Further opens are permitted.
290.It Dv TIOCFLUSH Fa int *what 298.It Dv TIOCFLUSH Fa int *what
291If the value of the int pointed to by 299If the value of the int pointed to by
292.Fa what 300.Fa what
293contains the 301contains the
294.Dv FREAD 302.Dv FREAD
295bit as defined in 303bit as defined in
296.In sys/fcntl.h , 304.In sys/fcntl.h ,
297then all characters in the input queue are cleared. If it contains 305then all characters in the input queue are cleared.
298the 306If it contains the
299.Dv FWRITE 307.Dv FWRITE
300bit, then all characters in the output queue are cleared. If the 308bit, then all characters in the output queue are cleared.
301value of the integer is zero, then it behaves as if both the 309If the value of the integer is zero, then it behaves as if both the
302.Dv FREAD 310.Dv FREAD
303and 311and
304.Dv FWRITE 312.Dv FWRITE
305bits were set (i.e. clears both queues). 313bits were set (i.e. clears both queues).
306.It Dv TIOCGWINSZ Fa struct winsize *ws 314.It Dv TIOCGWINSZ Fa struct winsize *ws
307Put the window size information associated with the terminal in the 315Put the window size information associated with the terminal in the
308.Va winsize 316.Va winsize
309structure pointed to by 317structure pointed to by
310.Fa ws . 318.Fa ws .
311The window size structure contains the number of rows and columns (and pixels 319The window size structure contains the number of rows and columns (and pixels
312if appropriate) of the devices attached to the terminal. It is set by user software 320if appropriate) of the devices attached to the terminal.
313and is the means by which most full\&-screen oriented programs determine the 321It is set by user software and is the means by which most full\&-screen
314screen size. The 322oriented programs determine the screen size.
 323The
315.Va winsize 324.Va winsize
316structure is defined in 325structure is defined in
317.In sys/ioctl.h . 326.In sys/ioctl.h .
318.It Dv TIOCSWINSZ Fa struct winsize *ws 327.It Dv TIOCSWINSZ Fa struct winsize *ws
319Set the window size associated with the terminal to be the value in 328Set the window size associated with the terminal to be the value in
320the 329the
321.Va winsize 330.Va winsize
322structure pointed to by 331structure pointed to by
323.Fa ws 332.Fa ws
324(see above). 333(see above).
325.It Dv TIOCCONS Fa int *on 334.It Dv TIOCCONS Fa int *on
326If 335If
327.Fa on 336.Fa on
328points to a non-zero integer, redirect kernel console output (kernel printf's) 337points to a non-zero integer, redirect kernel console output (kernel printf's)
329to this terminal. 338to this terminal.
330If 339If
331.Fa on 340.Fa on
332points to a zero integer, redirect kernel console output back to the normal 341points to a zero integer, redirect kernel console output back to the normal
333console. This is usually used on workstations to redirect kernel messages 342console.
 343This is usually used on workstations to redirect kernel messages
334to a particular window. 344to a particular window.
335.It Dv TIOCMSET Fa int *state 345.It Dv TIOCMSET Fa int *state
336The integer pointed to by 346The integer pointed to by
337.Fa state 347.Fa state
338contains bits that correspond to modem state. 348contains bits that correspond to modem state.
339Following is a list of defined variables and the modem state they represent: 349Following is a list of defined variables and the modem state they represent:
340.Pp 350.Pp
341.Bl -tag -width TIOCMXCTS -compact 351.Bl -tag -width TIOCMXCTS -compact
342.It TIOCM_LE 352.It TIOCM_LE
343Line Enable. 353Line Enable.
344.It TIOCM_DTR 354.It TIOCM_DTR
345Data Terminal Ready. 355Data Terminal Ready.
346.It TIOCM_RTS 356.It TIOCM_RTS
@@ -408,29 +418,29 @@ Set the @@ -408,29 +418,29 @@ Set the
408.Dv MDMBUF 418.Dv MDMBUF
409flag on open. 419flag on open.
410.El 420.El
411.Pp 421.Pp
412This call sets the serial port state to that represented by 422This call sets the serial port state to that represented by
413.Fa state . 423.Fa state .
414Not all serial ports may support this. 424Not all serial ports may support this.
415.It Dv TIOCGFLAGS Fa int *state 425.It Dv TIOCGFLAGS Fa int *state
416Return the current state of the serial port as represented 426Return the current state of the serial port as represented
417above in the integer pointed to by 427above in the integer pointed to by
418.Fa state . 428.Fa state .
419.El 429.El
420.Sh COMPATIBILITY 430.Sh COMPATIBILITY
421Two ioctls are maintained for backwards compatibility. They provide 431Two ioctls are maintained for backwards compatibility.
422methods to get and set the current line discipline, but are not 432They provide methods to get and set the current line discipline,
423extensible. 433but are not extensible.
424.Bl -tag -width TIOCGWINSZ 434.Bl -tag -width TIOCGWINSZ
425.It Dv TIOCSETD Fa int *ldisc 435.It Dv TIOCSETD Fa int *ldisc
426Change to the new line discipline pointed to by 436Change to the new line discipline pointed to by
427.Fa ldisc . 437.Fa ldisc .
428The old list of available line disciplines are listed in 438The old list of available line disciplines are listed in
429.In sys/ttycom.h 439.In sys/ttycom.h
430and are: 440and are:
431.Pp 441.Pp
432.Bl -tag -width TIOCGWINSZ -compact 442.Bl -tag -width TIOCGWINSZ -compact
433.It TTYDISC 443.It TTYDISC
434Termios interactive line discipline. 444Termios interactive line discipline.
435.It TABLDISC 445.It TABLDISC
436Tablet line discipline. 446Tablet line discipline.
@@ -448,16 +458,18 @@ Return the current line discipline in th @@ -448,16 +458,18 @@ Return the current line discipline in th
448.El 458.El
449.Sh SEE ALSO 459.Sh SEE ALSO
450.Xr stty 1 , 460.Xr stty 1 ,
451.Xr ioctl 2 , 461.Xr ioctl 2 ,
452.Xr tcgetattr 3 , 462.Xr tcgetattr 3 ,
453.Xr tcsetattr 3 , 463.Xr tcsetattr 3 ,
454.Xr ttyaction 3 , 464.Xr ttyaction 3 ,
455.Xr pty 4 , 465.Xr pty 4 ,
456.Xr termios 4 , 466.Xr termios 4 ,
457.Xr ttys 5 , 467.Xr ttys 5 ,
458.Xr getty 8 , 468.Xr getty 8 ,
459.Xr linedisc 9 469.Xr linedisc 9
460.Sh HISTORY 470.Sh HISTORY
461Separate dial-out device files were implemented in SunOS 4. They were cloned 471Separate dial-out device files were implemented in SunOS 4.
462by Charles M. Hannum for 472They were cloned by
 473.An Charles M. Hannum
 474for
463.Nx 1.4 . 475.Nx 1.4 .