I never really understood how a terminal emulator (be it e.g. XTerm or the Linux virtual console) works. What transformations happen to the input (key up/down events) to produce the output (usually the standard input of the application that is running in the terminal, a signal being sent and so on)? What is actually the input for the terminal and what is already handled by the input drivers (in the kernel, X server, ...). How and where do the terminal capabilities databases like terminfo or termcap enter this process? How are "special" keys like arrows processed? And conversely: how does it work the other way round: application standard output/error → medium (screen, paper)?

  • 3
    some answers there. You might want to break this down into several questions. Otherwise it's going to be too broad. – Stéphane Chazelas Sep 29 '14 at 20:35
  • Well, I wouldn't say exactly "broad" but definitely "long". I'll read your answer on the other question thoroughly and will try to refactor this question into several (linked) parts tomorrow. Thanks! – peterph Sep 29 '14 at 21:10
  • @StéphaneChazelas actually your answer in the other question provided me with an important search term: line discipline. I'll have to read about that a bit more to make sure what pieces of the puzzle will be still missing. – peterph Sep 29 '14 at 21:26
  • I'm voting to close as a duplicate of unix.stackexchange.com/questions/116629/… which presents a high-level view. Together with Stéphane's excellent detailed answer, I think this provides as good a presentation of what you're asking here as it gets. You're welcome to edit your question if there are points that you feel are missing. – Gilles 'SO- stop being evil' Sep 29 '14 at 23:26

Browse other questions tagged or ask your own question.