manual page distributed with 4.2BSD
[unix-history] / usr / src / share / man / man4 / tty.4
CommitLineData
02d430a1
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
d90ee9fb 5.\" @(#)tty.4 6.1 (Berkeley) %G%
02d430a1 6.\"
d90ee9fb 7.TH TTY 4 ""
02d430a1
KM
8.UC 4
9.SH NAME
10tty \- general terminal interface
9313e78d
KM
11.SH SYNOPSIS
12.B #include <sgtty.h>
02d430a1
KM
13.SH DESCRIPTION
14This section describes
15both a particular special file
16.B /dev/tty
17and the terminal drivers used for conversational computing.
18.LP
19.B Line disciplines.
20.PP
21The system provides different
22.I "line disciplines"
23for controlling communications lines.
24In this version of the system there are three disciplines available:
25.IP "old" 8
26The old (standard) terminal driver. This is used when using the
27standard shell
28.IR sh (1)
29and for compatibility with other standard version 7 UNIX systems.
30.IP "new"
31A newer terminal driver, with features for job control; this must
32be used when using
33.IR csh (1).
02d430a1
KM
34.IP "net"
35A line discipline used for networking and loading data into
36the system over communications lines. It allows high speed input
37at very low overhead, and is described in
38.IR bk (4).
39.LP
40Line discipline switching is accomplished with the TIOCSETD
41.I ioctl:
42.IP
43.B "int ldisc = LDISC; ioctl(filedes, TIOCSETD, &ldisc);"
44.LP
45where LDISC is OTTYDISC for the standard tty driver, NTTYDISC for the new
46driver and NETLDISC for the networking discipline.
47The standard (currently old) tty driver is discipline 0 by convention.
48The current line discipline can be obtained with the TIOCGETD ioctl.
49Pending input is discarded when the line discipline is changed.
50.PP
51All of the low-speed asynchronous
52communications ports can use any
53of the available line disciplines, no matter what
54hardware is involved.
55The remainder of this section discusses the
56\*(lqold\*(rq and \*(lqnew\*(rq disciplines.
57.LP
58.B "The control terminal."
59.LP
60When a terminal file is opened, it causes the process to wait until a
61connection is established. In practice, user programs seldom open
62these files; they are opened by
63.IR init (8)
64and become a user's standard input and output file.
65.PP
66If a process which has no control terminal opens a terminal file, then
67that terminal file becomes the control terminal for that process.
68The control terminal is thereafter inherited by a child process during a
69.IR fork (2),
70even if the control terminal is closed.
71.LP
72The file
73.B /dev/tty
74is, in each process, a synonym for a
75.I "control terminal"
76associated with that process. It is useful for programs that wish to
77be sure of writing messages on the terminal
78no matter how output has been redirected.
79It can also be used for programs that demand a file name
80for output, when typed output is desired
81and it is tiresome to find out which terminal
82is currently in use.
83.LP
84.B "Process groups."
85.LP
9313e78d 86Command processors such as
02d430a1
KM
87.IR csh (1)
88can arbitrate the terminal between different
89.I jobs
90by placing related jobs in a single process group and associating this
91process group with the terminal. A terminals associated process group
92may be set using the TIOCSPGRP
93.IR ioctl (2):
94.IP
95\fBioctl(fildes, TIOCSPGRP, &pgrp)\fR
96.LP
97or examined using TIOCGPGRP rather than TIOCSPGRP, returning the current
98process group in
99.I pgrp.
100The new terminal driver aids in this arbitration by restricting access
101to the terminal by processes which are not in the current process group;
102see
103.B "Job access control"
104below.
105.LP
106.B "Modes."
107.PP
108The terminal drivers have three major modes, characterized by the
109amount of processing on the input and output characters:
110.IP cooked 10
111The normal mode. In this mode lines of input are collected and input editing
112is done. The edited line is made available when it is completed by
113a newline
114or when an EOT (control-D, hereafter ^D)
115is entered.
116A carriage return is usually made synonymous with newline in this mode,
117and replaced with a newline whenever it is typed.
118All driver functions
119(input editing, interrupt generation,
120output processing such as delay generation and tab expansion, etc.)
121are available in this mode.
122.IP CBREAK 10
123This mode eliminates the character, word, and line editing input facilities,
124making the input character available to the user program as it is typed.
125Flow control, literal-next and interrupt processing are still done in this mode.
126Output processing is done.
127.IP RAW 10
128This mode eliminates all input processing and makes all input characters
129available as they are typed; no output processing is done either.
130.PP
9313e78d
KM
131The style of input processing can also be very different when
132the terminal is put in non-blocking i/o mode; see
133.IR fcntl (2).
134In this case a
02d430a1
KM
135.IR read (2)
136from the control terminal will never block, but rather
9313e78d
KM
137return an error indication (EWOULDBLOCK) if there is no
138input available.
139.PP
140A process may also request a SIGIO signal be sent it whenever input
141is present. To enable this mode the FASYNC flag should be set using
142.IR fcntl (2).
02d430a1
KM
143.LP
144.B "Input editing."
145.LP
146A UNIX terminal ordinarily operates in full-duplex mode.
147Characters may be typed at any time,
148even while output is occurring, and are only lost when the
149system's character input buffers become completely
150choked, which is rare,
151or when the user has accumulated the maximum allowed number of
152input characters that have not yet been read by some program.
153Currently this limit is 256 characters.
154In the old terminal driver all the saved characters are thrown away
155when the limit is reached, without notice; the new driver simply refuses
156to accept any further input, and rings the terminal bell.
157.PP
158Input characters are normally accepted in either even or odd parity
159with the parity bit being stripped off before the character is given to
160the program. By clearing either the EVEN or ODD bit in the flags word
161it is possible to have input characters with that parity discarded (see the
162\fBSummary\fR below.)
163.PP
164In all of the line disciplines, it is possible to simulate terminal
165input using the TIOCSTI ioctl, which takes, as its third argument,
166the address of a character. The system pretends that this character
167was typed on the argument terminal, which must be the control terminal except
9313e78d 168for the super-user (this call is not in standard version 7 UNIX).
02d430a1
KM
169.PP
170Input characters are normally echoed by putting them in an output queue
171as they arrive. This may be disabled by clearing the ECHO bit in the
172flags word using the
9313e78d 173.IR stty (3)
02d430a1
KM
174call or the TIOCSETN or TIOCSETP ioctls
175(see the \fBSummary\fR below).
176.PP
177In cooked mode, terminal input is processed in units of lines.
178A program attempting
179to read will normally be suspended until an entire line has been
180received
181(but see the description of SIGTTIN in \fBModes\fR above and FIONREAD in
182\fBSummary\fR below.)
183No matter how many characters are requested
184in the read call, at most one line will be returned.
185It is not, however, necessary to read a whole line at
186once; any number of characters may be
187requested in a read, even one, without losing information.
188.PP
189During input, line editing is normally done, with the character `#'
190logically erasing the last character typed and the character `@'
191logically erasing the entire current input line.
192These are often reset on crt's,
193with ^H replacing #,
194and ^U replacing @.
195These characters
196never erase beyond the beginning of the current input line or an ^D.
197These characters may be entered literally by
198preceding them with `\e\|'; in the old teletype driver both the `\e\|' and
199the character entered literally will appear on the screen; in the new
200driver the `\e\|' will normally disappear.
201.PP
202The drivers normally treat either a carriage return or a newline character
203as terminating an input line, replacing the return with a newline and echoing
204a return and a line feed.
205If the CRMOD bit is cleared in the local mode word then the processing
206for carriage return is disabled, and it is simply echoed as a return,
207and does not terminate cooked mode input.
208.PP
209In the new driver there is a literal-next character ^V which can be typed
210in both cooked and CBREAK mode preceding
211.B any
212character to prevent its special meaning. This is to be preferred to the
213use of `\e\|' escaping erase and kill characters, but `\e\|' is (at least
214temporarily) retained with its old function in the new driver for historical
215reasons.
216.PP
217The new terminal driver also provides two other editing characters in
218normal mode. The word-erase character, normally ^W, erases the preceding
219word, but not any spaces before it. For the purposes of ^W, a word
220is defined as a sequence of non-blank characters, with tabs counted as
221blanks.
222Finally, the reprint character, normally ^R, retypes the pending input beginning
9313e78d 223on a new line. Retyping occurs automatically in cooked mode if characters
02d430a1
KM
224which would normally be erased from the screen are fouled by program output.
225.LP
226.B "Input echoing and redisplay"
227.LP
228In the old terminal driver, nothing special occurs when an erase character
229is typed; the erase character is simply echoed. When a kill character
230is typed it is echoed followed by a new-line (even if the character is
231not killing the line, because it was preceded by a `\e\|'!.)
232.PP
233The new terminal driver has several modes for handling the echoing of
234terminal input, controlled by bits in a local mode word.
235.LP
236.I "Hardcopy terminals."
237When a hardcopy terminal is in use, the LPRTERA bit is normally set in
238the local mode word. Characters which are logically erased are
239then printed out backwards preceded by `\e\|' and followed by `/' in this mode.
240.LP
241.I "Crt terminals."
242When a crt terminal is in use, the LCRTBS bit is normally set in the local
243mode word. The terminal driver then echoes the proper number of erase
244characters when input is erased; in the normal case where the erase
245character is a ^H this causes the cursor of the terminal to back up
246to where it was before the logically erased character was typed.
247If the input has become fouled due to interspersed asynchronous output,
9313e78d 248the input is automatically retyped.
02d430a1
KM
249.LP
250.I "Erasing characters from a crt."
251When a crt terminal is in use, the LCRTERA bit may be set to cause
252input to be erased from the screen with a \*(lqbackspace-space-backspace\*(rq
253sequence when character or word deleting sequences are used.
254A LCRTKIL bit may be set as well, causing the input to
255be erased in this manner on line kill sequences as well.
256.LP
257.I "Echoing of control characters."
258If the LCTLECH bit is set in the local state word, then non-printing (control)
259characters are normally echoed as ^X (for some X)
260rather than being echoed unmodified; delete is echoed as ^?.
261.LP
262The normal modes for using the new terminal driver on crt terminals
263are speed dependent.
264At speeds less than 1200 baud, the LCRTERA and LCRTKILL processing
265is painfully slow, so
266.IR stty (1)
267normally just sets LCRTBS and LCTLECH; at
268speeds of 1200 baud or greater all of these bits are normally set.
269.IR Stty (1)
270summarizes these option settings and the use of the new terminal
271driver as
272\*(lqnewcrt.\*(rq
273.LP
274.B "Output processing."
275.PP
276When one or more
277characters are written, they are actually transmitted
278to the terminal as soon as previously-written characters
279have finished typing.
280(As noted above, input characters are normally
281echoed by putting them in the output queue
282as they arrive.)
283When a process produces characters more rapidly than they can be typed,
284it will be suspended when its output queue exceeds some limit.
285When the queue has drained down to some threshold
286the program is resumed.
287Even parity is normally generated on output.
288The EOT character is not transmitted in cooked mode to prevent terminals
289that respond to it from hanging up; programs using raw or cbreak mode
290should be careful.
291.PP
292The terminal drivers provide necessary processing for cooked and CBREAK mode
293output including delay generation for certain special characters and parity
294generation. Delays are available after backspaces ^H, form feeds ^L,
295carriage returns ^M, tabs ^I and newlines ^J. The driver will also optionally
296expand tabs into spaces, where the tab stops are assumed to be set every
297eight columns. These functions are controlled by bits in the tty flags word;
298see \fBSummary\fR below.
299.PP
300The terminal drivers provide for mapping between upper and lower case
301on terminals lacking lower case, and for other special processing on
302deficient terminals.
303.PP
304Finally, in the new terminal driver, there is a output flush character,
305normally ^O, which sets the LFLUSHO bit in the local mode word, causing
306subsequent output to be flushed until it is cleared by a program or more
307input is typed. This character has effect in both cooked and CBREAK modes
308and causes pending input to be retyped if there is any pending input.
9313e78d
KM
309An ioctl to flush the characters in the input and output queues TIOCFLUSH,
310is also available.
02d430a1
KM
311.LP
312.B "Upper case terminals and Hazeltines"
313.PP
314If the LCASE bit is set in the tty flags, then
315all upper-case letters are mapped into
316the corresponding lower-case letter.
317The upper-case letter may be generated by preceding
318it by `\\'.
319If the new terminal driver is being used,
320then upper case letters
321are preceded by a `\e\|' when output.
322In addition, the following escape sequences can be generated
323on output and accepted on input:
324.PP
325.nf
326for \` | ~ { }
327use \e\|\' \e\|! \e\|^ \e\|( \e\|)
328.fi
329.PP
330To deal with Hazeltine terminals, which do not understand that ~ has
331been made into an ASCII character, the LTILDE bit may be set in the local
332mode word when using the new terminal driver; in this case the character
333~ will be replaced with the character \` on output.
334.LP
335.B "Flow control."
336.PP
337There are two characters (the stop character, normally ^S, and the
338start character, normally ^Q) which cause output to be suspended and
339resumed respectively. Extra stop characters typed when output
340is already stopped have no effect, unless the start and stop characters
341are made the same, in which case output resumes.
342.PP
343A bit in the flags word may be set to put the terminal into TANDEM mode.
344In this mode the system produces a stop character (default ^S) when
345the input queue is in danger of overflowing, and a start character (default
346^Q) when the input has drained sufficiently. This mode is useful
347when the terminal is actually another machine that obeys the
348conventions.
349.LP
350.B "Line control and breaks."
351.LP
352There are several
353.I ioctl
354calls available to control the state of the terminal line.
355The TIOCSBRK ioctl will set the break bit in the hardware interface
356causing a break condition to exist; this can be cleared (usually after a delay
357with
358.IR sleep (3))
359by TIOCCBRK.
360Break conditions in the input are reflected as a null character in RAW mode
361or as the interrupt character in cooked or CBREAK mode.
362The TIOCCDTR ioctl will clear the data terminal ready condition; it can
363be set again by TIOCSDTR.
364.PP
365When the carrier signal from the dataset drops (usually
366because the user has hung up his terminal) a
367SIGHUP hangup signal is sent to the processes in the distinguished
368process group of the terminal; this usually causes them to terminate
369(the SIGHUP can be suppressed by setting the LNOHANG bit in the local
370state word of the driver.)
371Access to the terminal by other processes is then normally revoked,
372so any further reads will fail, and programs that read a terminal and test for
373end-of-file on their input will terminate appropriately.
374.PP
375When using an ACU
376it is possible to ask that the phone line be hung up on the last close
377with the TIOCHPCL ioctl; this is normally done on the outgoing line.
378.LP
379.B "Interrupt characters."
380.PP
381There are several characters that generate interrupts in cooked and CBREAK
382mode; all are sent the processes in the control group of the terminal,
383as if a TIOCGPGRP ioctl were done to get the process group and then a
384.IR killpg (2)
385system call were done,
386except that these characters also flush pending input and output when
387typed at a terminal
388(\fI\z'a\`'la\fR TIOCFLUSH).
389The characters shown here are the defaults; the field names in the structures
390(given below)
391are also shown.
392The characters may be changed,
393although this is not often done.
394.IP ^?
9313e78d 395\fBt_intrc\fR (Delete) generates a SIGINT signal.
02d430a1
KM
396This is the normal way to stop a process which is no longer interesting,
397or to regain control in an interactive program.
398.IP ^\e
399\fBt_quitc\fR (FS) generates a SIGQUIT signal.
400This is used to cause a program to terminate and produce a core image,
401if possible,
402in the file
403.B core
404in the current directory.
405.IP ^Z
406\fBt_suspc\fR (EM) generates a SIGTSTP signal, which is used to suspend
407the current process group.
408.IP ^Y
9313e78d 409\fBt_dsuspc\fR (SUB) generates a SIGTSTP signal as ^Z does, but the
02d430a1
KM
410signal is sent when a program attempts to read the ^Y, rather than when
411it is typed.
412.LP
413.B "Job access control."
414.PP
415When using the new terminal driver,
416if a process which is not in the distinguished process group of its
417control terminal attempts to read from that terminal its process group is
9313e78d
KM
418sent a SIGTTIN signal. This signal normally causes the members of
419that process group to stop.
420If, however, the process is ignoring SIGTTIN, has SIGTTIN blocked,
421is an
422.IR "orphan process" ,
423or is in the middle of process creation using
02d430a1 424.IR vfork (2)),
9313e78d
KM
425it is instead returned an end-of-file. (An
426.I "orphan process"
427is a process whose
428parent has exited and has been inherited by the
429.IR init (8)
430process.)
431Under older UNIX systems
02d430a1
KM
432these processes would typically have had their input files reset to
433.B /dev/null,
434so this is a compatible change.
435.PP
436When using the new terminal driver with the LTOSTOP bit set in the local
437modes, a process is prohibited from writing on its control terminal if it is
438not in the distinguished process group for that terminal.
439Processes which are holding or ignoring SIGTTOU signals, which are
440orphans, or which are in the middle of a
441.IR vfork (2)
442are excepted and allowed to produce output.
443.LP
444.B "Summary of modes."
445.LP
446Unfortunately, due to the evolution of the terminal driver,
447there are 4 different structures which contain various portions of the
448driver data. The first of these (\fBsgttyb\fR)
449contains that part of the information
450largely common between version 6 and version 7 UNIX systems.
451The second contains additional control characters added in version 7.
452The third is a word of local state peculiar to the new terminal driver,
453and the fourth is another structure of special characters added for the
454new driver. In the future a single structure may be made available
455to programs which need to access all this information; most programs
456need not concern themselves with all this state.
457.de Ul
458.ie t \\$1\l'|0\(ul'
459.el \fI\\$1\fP
460..
461.LP
462.Ul "Basic modes: sgtty."
463.PP
464The basic
465.IR ioctl s
466use the structure
467defined in
468.IR <sgtty.h> :
469.PP
470.ta .5i 1i
471.nf
472.ft 3
473struct sgttyb {
474 char sg_ispeed;
475 char sg_ospeed;
476 char sg_erase;
477 char sg_kill;
478 short sg_flags;
479};
480.ft R
481.fi
482.PP
483The
484.I sg_ispeed
485and
486.I sg_ospeed
487fields describe the input and output speeds of the
488device according to the following table,
489which corresponds to the DEC DH-11 interface.
490If other hardware is used,
491impossible speed changes are ignored.
492Symbolic values in the table are as defined in
493.IR <sgtty.h> .
494.PP
495.nf
496.ta \w'B9600 'u +5n
497B0 0 (hang up dataphone)
498B50 1 50 baud
499B75 2 75 baud
500B110 3 110 baud
501B134 4 134.5 baud
502B150 5 150 baud
503B200 6 200 baud
504B300 7 300 baud
505B600 8 600 baud
506B1200 9 1200 baud
507B1800 10 1800 baud
508B2400 11 2400 baud
509B4800 12 4800 baud
510B9600 13 9600 baud
511EXTA 14 External A
512EXTB 15 External B
513.fi
514.DT
515.PP
516In the current configuration,
517only 110, 150, 300 and 1200 baud are really supported on dial-up lines.
518Code conversion and line control required for
519IBM 2741's (134.5 baud)
520must be implemented by the user's
521program.
522The half-duplex line discipline
523required for the 202 dataset (1200 baud)
524is not supplied; full-duplex 212 datasets work fine.
525.PP
526The
527.I sg_erase
528and
529.I sg_kill
530fields of the argument structure
531specify the erase and kill characters respectively.
532(Defaults are # and @.)
533.PP
534The
535.I sg_flags
536field of the argument structure
537contains several bits that determine the
538system's treatment of the terminal:
539.PP
540.ta \w'ALLDELAY 'u +\w'0100000 'u
541.nf
542ALLDELAY 0177400 Delay algorithm selection
543BSDELAY 0100000 Select backspace delays (not implemented):
544BS0 0
545BS1 0100000
546VTDELAY 0040000 Select form-feed and vertical-tab delays:
547FF0 0
548FF1 0100000
549CRDELAY 0030000 Select carriage-return delays:
550CR0 0
551CR1 0010000
552CR2 0020000
553CR3 0030000
554TBDELAY 0006000 Select tab delays:
555TAB0 0
556TAB1 0001000
557TAB2 0004000
558XTABS 0006000
559NLDELAY 0001400 Select new-line delays:
560NL0 0
561NL1 0000400
562NL2 0001000
563NL3 0001400
564EVENP 0000200 Even parity allowed on input (most terminals)
565ODDP 0000100 Odd parity allowed on input
566RAW 0000040 Raw mode: wake up on all characters, 8-bit interface
567CRMOD 0000020 Map CR into LF; echo LF or CR as CR-LF
568ECHO 0000010 Echo (full duplex)
569LCASE 0000004 Map upper case to lower on input
570CBREAK 0000002 Return each character as soon as typed
571TANDEM 0000001 Automatic flow control
572.DT
573.fi
574.PP
575The delay bits specify how long
576transmission stops to allow for mechanical or other movement
577when certain characters are sent to the terminal.
578In all cases a value of 0 indicates no delay.
579.PP
580Backspace delays are currently ignored but might
581be used for Terminet 300's.
582.PP
583If a form-feed/vertical tab delay is specified,
584it lasts for about 2 seconds.
585.PP
586Carriage-return delay type 1 lasts about .08 seconds
587and is suitable for the Terminet 300.
588Delay type 2 lasts about .16 seconds and is suitable
589for the VT05 and the TI 700.
590Delay type 3 is suitable for the concept-100 and pads lines
591to be at least 9 characters at 9600 baud.
592.PP
593New-line delay type 1 is dependent on the current column
594and is tuned for Teletype model 37's.
595Type 2 is useful for the VT05 and is about .10 seconds.
596Type 3 is unimplemented and is 0.
597.PP
598Tab delay type 1 is dependent on the amount of movement
599and is tuned to the Teletype model
60037.
601Type 3, called XTABS,
602is not a delay at all but causes tabs to be replaced
603by the appropriate number of spaces on output.
604.PP
605Input characters with the wrong parity, as determined by bits 200 and
606100, are ignored in cooked and CBREAK mode.
607.PP
608RAW
609disables all processing save output flushing with LFLUSHO;
610full 8 bits of input are given as soon as
611it is available; all 8 bits are passed on output.
612A break condition in the input is reported as a null character.
613If the input queue overflows in raw mode it is discarded; this applies
614to both new and old drivers.
615.PP
616CRMOD causes input carriage returns to be turned into
617new-lines;
618input of either CR or LF causes LF-CR both to
619be echoed
620(for terminals with a new-line function).
621.PP
622CBREAK is a sort of half-cooked (rare?) mode.
623Programs can read each character as soon as typed, instead
624of waiting for a full line;
625all processing is done except the input editing:
626character and word erase and line kill, input reprint,
627and the special treatment of \e or EOT are disabled.
628.PP
629TANDEM mode causes the system to produce
630a stop character (default ^S) whenever the input
631queue is in danger of overflowing, and a start character
632(default ^Q)
633when the input queue has drained sufficiently.
634It is useful for flow control when the `terminal'
635is really another computer which understands the conventions.
636.LP
637.Ul "Basic ioctls"
638.PP
639In addition to the TIOCSETD and TIOCGETD disciplines discussed
640in \fBLine disciplines\fR above,
641a large number of other
642.IR ioctl (2)
643calls apply to terminals, and have the general form:
644.PP
645.B #include <sgtty.h>
646.PP
647.B ioctl(fildes, code, arg)
648.br
649.B struct sgttyb *arg;
650.PP
651The applicable codes are:
652.IP TIOCGETP 15
653Fetch the basic parameters associated with the terminal, and store
654in the pointed-to \fIsgttyb\fR structure.
655.IP TIOCSETP
656Set the parameters according to the pointed-to \fIsgttyb\fR structure.
657The interface delays until output is quiescent,
658then throws away any unread characters,
659before changing the modes.
660.IP TIOCSETN
661Set the parameters like TIOCSETP but do not delay or flush input.
662Input is not preserved, however, when changing to or from RAW.
663.PP
664With the following codes the
665.I arg
666is ignored.
667.IP TIOCEXCL 15
668Set \*(lqexclusive-use\*(rq mode:
669no further opens are permitted until the file has been closed.
670.IP TIOCNXCL
671Turn off \*(lqexclusive-use\*(rq mode.
672.IP TIOCHPCL
673When the file is closed for the last time,
674hang up the terminal.
675This is useful when the line is associated
676with an ACU used to place outgoing calls.
677.IP TIOCFLUSH
678All characters waiting in input or output queues are flushed.
679.LP
680The remaining calls are not available in vanilla version 7 UNIX.
681In cases where arguments are required, they are described; \fIarg\fR
682should otherwise be given as 0.
683.IP TIOCSTI 15
684the argument is the address of a character which the system
685pretends was typed on the terminal.
686.IP TIOCSBRK 15
687the break bit is set in the terminal.
688.IP TIOCCBRK
689the break bit is cleared.
690.IP TIOCSDTR
691data terminal ready is set.
692.IP TIOCCDTR
693data terminal ready is cleared.
694.IP TIOCGPGRP
695arg is the address of a word into which is placed the process group
696number of the control terminal.
697.IP TIOCSPGRP
698arg is a word (typically a process id) which becomes the process
699group for the control terminal.
700.IP FIONREAD
701returns in the long integer whose address is arg the number
702of immediately readable characters from the argument unit.
703This works for files, pipes, and terminals, but not (yet)
704for multiplexed channels.
705.LP
706.Ul Tchars
707.PP
708The second structure associated with each terminal specifies
709characters that are special in both the old and new terminal interfaces:
710The following structure is defined in
711.IR <sys/ioctl.h> ,
712which is automatically included in
713.IR <sgtty.h> :
714.PP
715.nf
716.ft 3
717.ta .5i 1i 2i
718struct tchars {
719 char t_intrc; /* interrupt */
720 char t_quitc; /* quit */
721 char t_startc; /* start output */
722 char t_stopc; /* stop output */
723 char t_eofc; /* end-of-file */
724 char t_brkc; /* input delimiter (like nl) */
725};
726.DT
727.fi
728.ft R
729.PP
730The default values for these characters are
731^?, ^\e\|, ^Q, ^S, ^D, and \-1.
732A character value of \-1
733eliminates the effect of that character.
734The
735.I t_brkc
736character, by default \-1,
737acts like a new-line in that it terminates a `line,'
738is echoed, and is passed to the program.
739The `stop' and `start' characters may be the same,
740to produce a toggle effect.
741It is probably counterproductive to make
742other special characters (including erase and kill)
743identical.
744The applicable ioctl calls are:
745.IP TIOCGETC 12
746Get the special characters and put them in the specified structure.
747.IP TIOCSETC 12
748Set the special characters to those given in the structure.
749.LP
750.Ul "Local mode"
751.PP
752The third structure associated with each terminal is a local mode word;
753except for the LNOHANG bit, this word is interpreted only when the new
754driver is in use.
755The bits of the local mode word are:
756.sp
757.nf
758LCRTBS 000001 Backspace on erase rather than echoing erase
759LPRTERA 000002 Printing terminal erase mode
760LCRTERA 000004 Erase character echoes as backspace-space-backspace
761LTILDE 000010 Convert ~ to \` on output (for Hazeltine terminals)
762LMDMBUF 000020 Stop/start output when carrier drops
763LLITOUT 000040 Suppress output translations
764LTOSTOP 000100 Send SIGTTOU for background output
765LFLUSHO 000200 Output is being flushed
766LNOHANG 000400 Don't send hangup when carrier drops
767LETXACK 001000 Diablo style buffer hacking (unimplemented)
768LCRTKIL 002000 BS-space-BS erase entire line on line kill
769LINTRUP 004000 Generate interrupt SIGTINT when input ready to read
770LCTLECH 010000 Echo input control chars as ^X, delete as ^?
771LPENDIN 020000 Retype pending input at next read or input character
772LDECCTQ 040000 Only ^Q restarts output after ^S, like DEC systems
773.fi
774.sp
775The applicable
776.I ioctl
777functions are:
778.IP TIOCLBIS 15
779arg is the address of a
780mask which is the bits to be set in the local mode word.
781.IP TIOCLBIC
782arg is the address of a mask of bits to be cleared in the local mode word.
783.IP TIOCLSET
784arg is the address of a mask to be placed in the local mode word.
785.IP TIOCLGET
786arg is the address of a word into which the current mask is placed.
787.LP
788.Ul "Local special chars"
789.PP
790The
791final structure associated with each terminal is the
792.I ltchars
793structure which defines interrupt characters
794for the new terminal driver.
795Its structure is:
796.nf
797.sp
798.ta .5i 1i 2i
799.ft B
800struct ltchars {
801 char t_suspc; /* stop process signal */
9313e78d 802 char t_dsuspc; /* delayed stop process signal */
02d430a1
KM
803 char t_rprntc; /* reprint line */
804 char t_flushc; /* flush output (toggles) */
9313e78d 805 char t_werasc; /* word erase */
02d430a1
KM
806 char t_lnextc; /* literal next character */
807};
808.ft R
809.fi
810.sp
811The default values for these characters are ^Z, ^Y, ^R, ^O, ^W, and ^V.
812A value of \-1 disables the character.
813.PP
814The applicable \fIioctl\fR functions are:
815.IP TIOCSLTC 12
816args is the address of a
817.I ltchars
818structure which defines the new local special characters.
819.IP TIOCGLTC 12
820args is the address of a
821.I ltchars
822structure into which is placed the current set of local special characters.
823.SH FILES
824/dev/tty
825.br
826/dev/tty*
827.br
828/dev/console
829.SH SEE ALSO
9313e78d
KM
830csh(1),
831stty(1),
832ioctl(2),
833sigvec(2),
834stty(3C),
835getty(8),
836init(8)
02d430a1
KM
837.SH BUGS
838Half-duplex terminals are not supported.