tty
Created at 2017-05-23T08:25:21+09:00

My long-standing questions and their answer (maybe wrong):

  • Q0. (pty) Who does send SIGINT to the foreground process of slave tty when master sends VINTR (Ctrl-C) ?
    • Kernel does since anyway special character handling can happen in kernel context.
  • Q1. (pty) how can the process listening on master tty know about ioctl on slave tty ?
    • select(2) can notify it.
  • Q2. how can foreground process control where to output (or move cursor) ? (e.g. clear(3x), clear(1))
    • everything beyond "dumb" terminal is terminal capability, which is handled by special character.

ncurses

Trying out:

[ gnome-terminal ]

$ env | grep -i term
COLORTERM=truecolor
TERM=xterm-256color

$ tput longname
xterm with 256 color

$ infocmp xterm-256color
#    Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm-256color
xterm-256color|xterm with 256 colors,
    am, bce, ccc, km, mc5i, mir, msgr, npc, xenl,
    colors#256, cols#80, it#8, lines#24, pairs#32767,
    acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
    bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
    clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=\r,
    csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
    cud=\E[%p1%dB, cud1=\n, cuf=\E[%p1%dC, cuf1=\E[C,
    cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
    cvvis=\E[?12;25h, dch=\E[%p1%dP, dch1=\E[P, dim=\E[2m,
    dl=\E[%p1%dM, dl1=\E[M, ech=\E[%p1%dX, ed=\E[J, el=\E[K,
    el1=\E[1K, flash=\E[?5h$<100/>\E[?5l, home=\E[H,
  ...

$ infocmp dumb # as in emacs's shell-mode or comint-mode
#    Reconstructed via infocmp from file: /usr/share/terminfo/d/dumb
dumb|80-column dumb tty,
    am,
    cols#80,
    bel=^G, cr=\r, cud1=\n, ind=\n,

$ tput cup <raw-index> <colum-index> # move cursor
[ Data structure ]
...

[ tput.c ]
- main =>
  - save_tty_settings => ?
  - setupterm => ?
  - tput_cmd =>
    - set_window_size
    - _nc_find_entry(name, _nc_get_hash_table(termcap))