Deleted Added
full compact
tty.4 (84306) tty.4 (117011)
1.\" Copyright (c) 1991, 1992, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 16 unchanged lines hidden (view full) ---

25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)tty.4 8.3 (Berkeley) 4/19/94
1.\" Copyright (c) 1991, 1992, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 16 unchanged lines hidden (view full) ---

25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" @(#)tty.4 8.3 (Berkeley) 4/19/94
33.\" $FreeBSD: head/share/man/man4/tty.4 84306 2001-10-01 16:09:29Z ru $
33.\" $FreeBSD: head/share/man/man4/tty.4 117011 2003-06-28 23:53:39Z ru $
34.\"
35.Dd August 14, 1992
36.Dt TTY 4
37.Os
38.Sh NAME
39.Nm tty
40.Nd general terminal interface
41.Sh SYNOPSIS

--- 14 unchanged lines hidden (view full) ---

56a hardware terminal port, but to another program on the other side.
57These special terminal devices are called
58.Em ptys
59and provide the mechanism necessary to give users the same interface to the
60system when logging in over a network (using
61.Xr rlogin 1 ,
62or
63.Xr telnet 1
34.\"
35.Dd August 14, 1992
36.Dt TTY 4
37.Os
38.Sh NAME
39.Nm tty
40.Nd general terminal interface
41.Sh SYNOPSIS

--- 14 unchanged lines hidden (view full) ---

56a hardware terminal port, but to another program on the other side.
57These special terminal devices are called
58.Em ptys
59and provide the mechanism necessary to give users the same interface to the
60system when logging in over a network (using
61.Xr rlogin 1 ,
62or
63.Xr telnet 1
64for example). Even in these cases the details of how the terminal
64for example).
65Even in these cases the details of how the terminal
65file was opened and set up is already handled by special software
66in the system.
67Thus, users do not normally need to worry about the details of
66file was opened and set up is already handled by special software
67in the system.
68Thus, users do not normally need to worry about the details of
68how these lines are opened or used. Also, these lines are often used
69how these lines are opened or used.
70Also, these lines are often used
69for dialing out of a system (through an out-calling modem), but again
70the system provides programs that hide the details of accessing
71these terminal special files (see
72.Xr tip 1 ) .
73.Pp
74When an interactive user logs in, the system prepares the line to
75behave in a certain way (called a
76.Em "line discipline" ) ,
77the particular details of which is described in
78.Xr stty 1
79at the command level, and in
80.Xr termios 4
71for dialing out of a system (through an out-calling modem), but again
72the system provides programs that hide the details of accessing
73these terminal special files (see
74.Xr tip 1 ) .
75.Pp
76When an interactive user logs in, the system prepares the line to
77behave in a certain way (called a
78.Em "line discipline" ) ,
79the particular details of which is described in
80.Xr stty 1
81at the command level, and in
82.Xr termios 4
81at the programming level. A user may be concerned with changing
83at the programming level.
84A user may be concerned with changing
82settings associated with his particular login terminal and should refer
85settings associated with his particular login terminal and should refer
83to the preceding man pages for the common cases. The remainder of
84this man page is concerned
86to the preceding man pages for the common cases.
87The remainder of this man page is concerned
85with describing details of using and controlling terminal devices
86at a low level, such as that possibly required by a program wishing
87to provide features similar to those provided by the system.
88.Ss Line disciplines
89A terminal file is used like any other file in the system in that
90it can be opened, read, and written to using standard system
88with describing details of using and controlling terminal devices
89at a low level, such as that possibly required by a program wishing
90to provide features similar to those provided by the system.
91.Ss Line disciplines
92A terminal file is used like any other file in the system in that
93it can be opened, read, and written to using standard system
91calls. For each existing terminal file, there is a software processing module
94calls.
95For each existing terminal file, there is a software processing module
92called a
93.Em "line discipline"
94is associated with it. The
95.Em "line discipline"
96essentially glues the low level device driver code with the high
97level generic interface routines (such as
98.Xr read 2
99and
100.Xr write 2 ) ,
101and is responsible for implementing the semantics associated
96called a
97.Em "line discipline"
98is associated with it. The
99.Em "line discipline"
100essentially glues the low level device driver code with the high
101level generic interface routines (such as
102.Xr read 2
103and
104.Xr write 2 ) ,
105and is responsible for implementing the semantics associated
102with the device. When a terminal file is first opened by a program,
103the default
106with the device.
107When a terminal file is first opened by a program, the default
104.Em "line discipline"
105called the
106.Dv termios
108.Em "line discipline"
109called the
110.Dv termios
107line discipline is associated with the file. This is the primary
111line discipline is associated with the file.
112This is the primary
108line discipline that is used in most cases and provides the semantics
113line discipline that is used in most cases and provides the semantics
109that users normally associate with a terminal. When the
114that users normally associate with a terminal.
115When the
110.Dv termios
111line discipline is in effect, the terminal file behaves and is
112operated according to the rules described in
113.Xr termios 4 .
114Please refer to that man page for a full description of the terminal
115semantics.
116The operations described here
117generally represent features common
118across all
119.Em "line disciplines" ,
120however some of these calls may not
121make sense in conjunction with a line discipline other than
122.Dv termios ,
123and some may not be supported by the underlying
124hardware (or lack thereof, as in the case of ptys).
125.Ss Terminal File Operations
126All of the following operations are invoked using the
127.Xr ioctl 2
116.Dv termios
117line discipline is in effect, the terminal file behaves and is
118operated according to the rules described in
119.Xr termios 4 .
120Please refer to that man page for a full description of the terminal
121semantics.
122The operations described here
123generally represent features common
124across all
125.Em "line disciplines" ,
126however some of these calls may not
127make sense in conjunction with a line discipline other than
128.Dv termios ,
129and some may not be supported by the underlying
130hardware (or lack thereof, as in the case of ptys).
131.Ss Terminal File Operations
132All of the following operations are invoked using the
133.Xr ioctl 2
128system call. Refer to that man page for a description of
129the
134system call.
135Refer to that man page for a description of the
130.Em request
131and
132.Em argp
133parameters.
134In addition to the ioctl
135.Em requests
136defined here, the specific line discipline
137in effect will define other
138.Em requests
139specific to it (actually
140.Xr termios 4
141defines them as function calls, not ioctl
142.Em requests . )
136.Em request
137and
138.Em argp
139parameters.
140In addition to the ioctl
141.Em requests
142defined here, the specific line discipline
143in effect will define other
144.Em requests
145specific to it (actually
146.Xr termios 4
147defines them as function calls, not ioctl
148.Em requests . )
143The following section lists the available ioctl requests. The
144name of the request, a description of its purpose, and the typed
149The following section lists the available ioctl requests.
150The name of the request, a description of its purpose, and the typed
145.Em argp
146parameter (if any)
147are listed. For example, the first entry says
148.Pp
149.D1 Em "TIOCSETD int *ldisc"
150.Pp
151and would be called on the terminal associated with
152file descriptor zero by the following code fragment:

--- 87 unchanged lines hidden (view full) ---

240call with the
241.Dv TCSAFLUSH
242option.
243.It Dv TIOCOUTQ Fa int *num
244Place the current number of characters in the output queue in the
245integer pointed to by
246.Fa num .
247.It Dv TIOCSTI Fa char *cp
151.Em argp
152parameter (if any)
153are listed. For example, the first entry says
154.Pp
155.D1 Em "TIOCSETD int *ldisc"
156.Pp
157and would be called on the terminal associated with
158file descriptor zero by the following code fragment:

--- 87 unchanged lines hidden (view full) ---

246call with the
247.Dv TCSAFLUSH
248option.
249.It Dv TIOCOUTQ Fa int *num
250Place the current number of characters in the output queue in the
251integer pointed to by
252.Fa num .
253.It Dv TIOCSTI Fa char *cp
248Simulate typed input. Pretend as if the terminal received the
249character pointed to by
254Simulate typed input.
255Pretend as if the terminal received the character pointed to by
250.Fa cp .
251.It Dv TIOCNOTTY Fa void
256.Fa cp .
257.It Dv TIOCNOTTY Fa void
252This call is obsolete but left for compatibility. In the past, when
253a process that didn't have a controlling terminal (see
258This call is obsolete but left for compatibility.
259In the past, when a process that didn't have a controlling terminal (see
254.Em The Controlling Terminal
255in
256.Xr termios 4 )
257first opened a terminal device, it acquired that terminal as its
260.Em The Controlling Terminal
261in
262.Xr termios 4 )
263first opened a terminal device, it acquired that terminal as its
258controlling terminal. For some programs this was a hazard as they
264controlling terminal.
265For some programs this was a hazard as they
259didn't want a controlling terminal in the first place, and this
260provided a mechanism to disassociate the controlling terminal from
266didn't want a controlling terminal in the first place, and this
267provided a mechanism to disassociate the controlling terminal from
261the calling process. It
268the calling process.
269It
262.Em must
263be called by opening the file
264.Pa /dev/tty
265and calling
266.Dv TIOCNOTTY
267on that file descriptor.
268.Pp
269The current system does not allocate a controlling terminal to
270a process on an
271.Fn open
272call: there is a specific ioctl called
273.Dv TIOSCTTY
274to make a terminal the controlling
275terminal.
276In addition, a program can
277.Fn fork
278and call the
279.Fn setsid
280system call which will place the process into its own session - which
270.Em must
271be called by opening the file
272.Pa /dev/tty
273and calling
274.Dv TIOCNOTTY
275on that file descriptor.
276.Pp
277The current system does not allocate a controlling terminal to
278a process on an
279.Fn open
280call: there is a specific ioctl called
281.Dv TIOSCTTY
282to make a terminal the controlling
283terminal.
284In addition, a program can
285.Fn fork
286and call the
287.Fn setsid
288system call which will place the process into its own session - which
281has the effect of disassociating it from the controlling terminal. This
282is the new and preferred method for programs to lose their controlling
289has the effect of disassociating it from the controlling terminal.
290This is the new and preferred method for programs to lose their controlling
283terminal.
284.It Dv TIOCSTOP Fa void
285Stop output on the terminal (like typing ^S at the keyboard).
286.It Dv TIOCSTART Fa void
287Start output on the terminal (like typing ^Q at the keyboard).
288.It Dv TIOCSCTTY Fa void
289Make the terminal the controlling terminal for the process (the process
290must not currently have a controlling terminal).
291.It Dv TIOCDRAIN Fa void
292Wait until all output is drained.
293.It Dv TIOCEXCL Fa void
291terminal.
292.It Dv TIOCSTOP Fa void
293Stop output on the terminal (like typing ^S at the keyboard).
294.It Dv TIOCSTART Fa void
295Start output on the terminal (like typing ^Q at the keyboard).
296.It Dv TIOCSCTTY Fa void
297Make the terminal the controlling terminal for the process (the process
298must not currently have a controlling terminal).
299.It Dv TIOCDRAIN Fa void
300Wait until all output is drained.
301.It Dv TIOCEXCL Fa void
294Set exclusive use on the terminal. No further opens are permitted
295except by root. Of course, this means that programs that are run by
302Set exclusive use on the terminal.
303No further opens are permitted except by root.
304Of course, this means that programs that are run by
296root (or setuid) will not obey the exclusive setting - which limits
297the usefulness of this feature.
298.It Dv TIOCNXCL Fa void
305root (or setuid) will not obey the exclusive setting - which limits
306the usefulness of this feature.
307.It Dv TIOCNXCL Fa void
299Clear exclusive use of the terminal. Further opens are permitted.
308Clear exclusive use of the terminal.
309Further opens are permitted.
300.It Dv TIOCFLUSH Fa int *what
301If the value of the int pointed to by
302.Fa what
303contains the
304.Dv FREAD
305bit as defined in
306.Aq Pa sys/file.h ,
310.It Dv TIOCFLUSH Fa int *what
311If the value of the int pointed to by
312.Fa what
313contains the
314.Dv FREAD
315bit as defined in
316.Aq Pa sys/file.h ,
307then all characters in the input queue are cleared. If it contains
308the
317then all characters in the input queue are cleared.
318If it contains the
309.Dv FWRITE
319.Dv FWRITE
310bit, then all characters in the output queue are cleared. If the
311value of the integer is zero, then it behaves as if both the
320bit, then all characters in the output queue are cleared.
321If the value of the integer is zero, then it behaves as if both the
312.Dv FREAD
313and
314.Dv FWRITE
315bits were set (i.e. clears both queues).
316.It Dv TIOCGWINSZ Fa struct winsize *ws
317Put the window size information associated with the terminal in the
318.Va winsize
319structure pointed to by
320.Fa ws .
321The window size structure contains the number of rows and columns (and pixels
322.Dv FREAD
323and
324.Dv FWRITE
325bits were set (i.e. clears both queues).
326.It Dv TIOCGWINSZ Fa struct winsize *ws
327Put the window size information associated with the terminal in the
328.Va winsize
329structure pointed to by
330.Fa ws .
331The window size structure contains the number of rows and columns (and pixels
322if appropriate) of the devices attached to the terminal. It is set by user software
332if appropriate) of the devices attached to the terminal.
333It is set by user software
323and is the means by which most full\&-screen oriented programs determine the
334and is the means by which most full\&-screen oriented programs determine the
324screen size. The
335screen size.
336The
325.Va winsize
326structure is defined in
327.Aq Pa sys/ioctl.h .
328.It Dv TIOCSWINSZ Fa struct winsize *ws
329Set the window size associated with the terminal to be the value in
330the
331.Va winsize
332structure pointed to by
333.Fa ws
334(see above).
335.It Dv TIOCCONS Fa int *on
336If
337.Fa on
338points to a non-zero integer, redirect kernel console output (kernel printf's)
339to this terminal.
340If
341.Fa on
342points to a zero integer, redirect kernel console output back to the normal
337.Va winsize
338structure is defined in
339.Aq Pa sys/ioctl.h .
340.It Dv TIOCSWINSZ Fa struct winsize *ws
341Set the window size associated with the terminal to be the value in
342the
343.Va winsize
344structure pointed to by
345.Fa ws
346(see above).
347.It Dv TIOCCONS Fa int *on
348If
349.Fa on
350points to a non-zero integer, redirect kernel console output (kernel printf's)
351to this terminal.
352If
353.Fa on
354points to a zero integer, redirect kernel console output back to the normal
343console. This is usually used on workstations to redirect kernel messages
355console.
356This is usually used on workstations to redirect kernel messages
344to a particular window.
345.It Dv TIOCMSET Fa int *state
346The integer pointed to by
347.Fa state
357to a particular window.
358.It Dv TIOCMSET Fa int *state
359The integer pointed to by
360.Fa state
348contains bits that correspond to modem state. Following is a list
349of defined variables and the modem state they represent:
361contains bits that correspond to modem state.
362Following is a list of defined variables and the modem state they represent:
350.Pp
351.Bl -tag -width TIOCMXCTS -compact
352.It TIOCM_LE
353Line Enable.
354.It TIOCM_DTR
355Data Terminal Ready.
356.It TIOCM_RTS
357Request To Send.

--- 55 unchanged lines hidden ---
363.Pp
364.Bl -tag -width TIOCMXCTS -compact
365.It TIOCM_LE
366Line Enable.
367.It TIOCM_DTR
368Data Terminal Ready.
369.It TIOCM_RTS
370Request To Send.

--- 55 unchanged lines hidden ---