home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / man / man4 / tty.4 < prev   
Encoding:
Text File  |  1975-06-26  |  6.9 KB  |  219 lines

  1. .th TTY IV 5/27/74
  2. .sh NAME
  3. tty \*- general typewriter interface
  4. .sh DESCRIPTION
  5. This section describes
  6. both a particular special file,
  7. and the general nature of the typewriter interface.
  8. .s3
  9. The file
  10. .it /dev/tty
  11. is, in each process, a synonym
  12. for the control typewriter associated with that process.
  13. It is useful for programs or Shell sequences which wish to
  14. be sure of writing messages on the typewriter
  15. no matter how output has been redirected.
  16. It can also be used for programs which demand a file name
  17. for output, when typed output is desired
  18. and it is tiresome to find out which typewriter
  19. is currently in use.
  20. .s3
  21. As for typewriters in general: all of the low-speed asynchronous
  22. communications ports use the
  23. same general interface, no matter what
  24. hardware is involved.
  25. The remainder of this section discusses
  26. the common features of the interface;
  27. the KL, DC, and DH writeups (IV) describe
  28. peculiarities of the individual devices.
  29. .s3
  30. When a typewriter file is opened, it causes
  31. the process to wait until a connection is established.
  32. In practice user's programs seldom open these
  33. files; they are opened by
  34. .it init
  35. and become a user's
  36. input and output file.
  37. The very first typewriter file open in a process becomes
  38. the
  39. .it "control typewriter"
  40. for that process.  The control typewriter plays a special
  41. role in handling quit or interrupt signals, as discussed
  42. below.
  43. The control typewriter is inherited by a child process during a
  44. .it fork.
  45. .s3
  46. A terminal associated with one of these files ordinarily
  47. operates in full-duplex mode.  Characters may be typed at any time,
  48. even while output is occurring, and are only lost when the
  49. system's character input buffers become completely
  50. choked, which is rare,
  51. or when the user has accumulated the maximum allowed number of
  52. input characters which have not yet been read by some program.
  53. Currently this limit is 256 characters.
  54. When the input limit is reached all the
  55. saved characters are thrown away without notice.
  56. .s3
  57. These special files have a number of modes which can be changed
  58. by use of the
  59. .it stty
  60. system call (II).
  61. When first opened,
  62. the interface mode is
  63. 300 baud;
  64. either parity accepted;
  65. 10 bits/character (one stop bit);
  66. and newline action character.
  67. Modes that can be changed by
  68. .it stty
  69. include
  70. the interface speed (if the hardware permits);
  71. acceptance of even parity, odd parity, or both;
  72. a raw mode in which all characters may be read one at a time;
  73. a carriage return (CR) mode in which
  74. CR is mapped into newline on input and
  75. either CR or line feed (LF) cause echoing of
  76. the sequence LF-CR;
  77. mapping of upper case letters into lower case;
  78. suppression of echoing;
  79. a variety of delays after function characters;
  80. and the printing of tabs as spaces.
  81. See
  82. .it getty
  83. (VIII)
  84. for the way that terminal speed and type are detected.
  85. .s3
  86. Normally, typewriter input is processed in units of lines.
  87. This means that a program attempting
  88. to read will be suspended until an entire line has been
  89. typed.  Also, no matter how many characters are requested
  90. in the read call, at most one line will be returned.
  91. It is not however necessary to read a whole line at
  92. once; any number of characters may be
  93. requested in a read, even one, without losing information.
  94. .s3
  95. During input, erase and kill processing is normally
  96. done.
  97. By default, the character `#' erases the
  98. last character typed, except that it will not erase
  99. beyond the beginning of a line or an EOT.
  100. By default, the character `@' kills the entire
  101. line up to the point where it was typed, but not beyond an EOT.  Both these
  102. characters operate on a keystroke basis independently
  103. of any backspacing or tabbing that may have been done.
  104. Either `@' or `#' may be entered literally by preceding
  105. it by `\\';
  106. the erase or kill character remains, but the
  107. `\\' disappears.
  108. These two characters may be changed to others.
  109. .s3
  110. When desired,
  111. all upper-case letters are mapped into
  112. the corresponding lower-case letter.
  113. The upper-case letter may be generated by preceding
  114. it by `\\'.
  115. In addition, the following escape sequences are generated
  116. on output and accepted on input:
  117. .s3
  118. .lp +14 7
  119. for    use
  120. .lp +15 7
  121. \*g    \\\*a
  122. .lp +15 7
  123. .br
  124. |    \\!
  125. .br
  126. .tr ??
  127. .lp +15 7
  128. ~    \\^
  129. .lp +15 7
  130. {    \\(
  131. .lp +15 7
  132. }    \\)
  133. .s3
  134. .i0
  135. In raw mode,
  136. the program
  137. reading is awakened on each character.
  138. No erase or kill processing is done;
  139. and the EOT, quit and interrupt characters
  140. are not treated specially.
  141. The input parity bit is passed back to the reader,
  142. but parity is still generated for output characters.
  143. .s3
  144. The ASCII EOT (control-D) character may be used to generate an end of file
  145. from a typewriter.
  146. When an EOT is received, all the characters
  147. waiting to be read are immediately passed to
  148. the program, without waiting for a new-line,
  149. and the EOT is discarded.
  150. Thus if there are no characters waiting, which
  151. is to say the EOT occurred at the beginning of a line,
  152. zero characters will be passed back, and this is
  153. the standard end-of-file indication.
  154. The EOT is passed back unchanged in raw mode.
  155. .s3
  156. When the carrier signal from the dataset drops (usually
  157. because the user has hung up his terminal)
  158. a
  159. .it hangup
  160. signal is sent to all processes with the typewriter
  161. as control typewriter.
  162. Unless other arrangements have been made,
  163. this signal causes the processes to terminate.
  164. If the hangup signal is ignored, any read
  165. returns with an end-of-file indication.
  166. Thus programs which read a typewriter and test for
  167. end-of-file on their input
  168. can terminate appropriately when
  169. hung up on.
  170. .s3
  171. Two characters have a special meaning when typed.
  172. The ASCII DEL character (sometimes called `rubout')
  173. is not passed to a program but generates
  174. an
  175. .it interrupt
  176. signal
  177. which is sent to all processes with the associated control typewriter.
  178. Normally each such process is forced to terminate,
  179. but arrangements may be made either to
  180. ignore the signal or to receive a
  181. trap to an agreed-upon location.
  182. See
  183. .it signal
  184. (II).
  185. .s3
  186. The ASCII character FS generates the
  187. .it quit
  188. signal.
  189. Its treatment is identical to the interrupt signal
  190. except that unless a receiving process has
  191. made other arrangements it will not only be terminated
  192. but a core image file will be generated.
  193. If you find it hard to type this character,
  194. try control-\\ or control-shift-L.
  195. .s3
  196. When one or more
  197. characters are written, they are actually transmitted
  198. to the terminal as soon as previously-written characters
  199. have finished typing.
  200. Input characters are echoed by putting them in the output queue
  201. as they arrive.
  202. When a process produces characters more rapidly than they can be typed,
  203. it will be suspended when its output queue exceeds some limit.
  204. When the queue has drained down to some threshold
  205. the program is resumed.
  206. Even parity is always generated on output.
  207. The EOT character is not transmitted
  208. (except in raw mode)
  209. to prevent terminals
  210. which respond to it from hanging up.
  211. .sh FILES
  212. /dev/tty
  213. .sh "SEE ALSO"
  214. dc (IV), kl (IV), dh (IV), getty (VIII), stty (I, II), gtty (I, II), signal (II)
  215. .sh BUGS
  216. Half-duplex terminals are not supported.
  217. On raw-mode output, parity should be transmitted as specified
  218. in the characters written.
  219.