14 Matching Annotations
  1. Sep 2021
    1. One good use for /dev/tty is if you're trying to call an editor in a pipeline (e.g., with xargs). Since the standard input of xargs is some list of files rather than your terminal, just doing, e.g., | xargs emacs will screw up your terminal. Instead you can use | xargs sh -c 'emacs "$@" </dev/tty' emacs to connect the editor to your terminal even though the input of xargs is coming from elsewhere.
  2. Apr 2021
    1. Going through different search systems brings us some fruits in the form of indistinct mumbling about the untimely closed I/O data streams, TTYs and PTYs (pseudoterminals) and all the rest of it.
    1. The role of the terminal emulator process is:

      Shows the relationship between a "terminal emulator" and a pseudoterminal, as alluded to in the intro:

      is a pair of pseudo-devices, one of which, the slave, emulates a hardware text terminal device, the other of which, the master, provides the means by which a terminal emulator process controls the slave.

    2. TTY is right there in the name, but this article makes no attempt to clarify what exactly the relationship between a pseudoterminal and a TTY. I feel like a whole paragraph about the relation to TTY would be warranted, including a link to TTY article, of course, which does link [back] to and explain some of the relation to pseudoterminal:

      In many computing contexts, "TTY" has become the name for any text terminal, such as an external console device, a user dialing into the system on a modem on a serial port device, a printing or graphical computer terminal on a computer's serial port or the RS-232 port on a USB-to-RS-232 converter attached to a computer's USB port, or even a terminal emulator application in the window system using a pseudoterminal device.

    3. In the BSD PTY system, the slave device file, which generally has a name of the form /dev/tty[p-za-e][0-9a-f], supports all system calls applicable to text terminal devices.
    1. In many computing contexts, "TTY" has become the name for any text terminal, such as an external console device, a user dialing into the system on a modem on a serial port device, a printing or graphical computer terminal on a computer's serial port or the RS-232 port on a USB-to-RS-232 converter attached to a computer's USB port, or even a terminal emulator application in the window system using a pseudoterminal device.

      It's still confusing, but this at least helps/tries to clarify.

    1. A "tty" neither has anything to do with rendering text.
    2. The virtual terminal process resides in kernel space (called the console).It reads from the "tty", say the output from the "ls" process and renders the text. It interacts with the VGA driver to do so.
    3. The (virtual) terminal (not the "tty") plays a central role here
    1. faketty() { script -qfc "$(printf "%q " "$@")" /dev/null }
      faketty() {
          script --return -qfc "$(printf "%q " "$@")" /dev/null
      }
      

      Now:

      ⟫ faketty python -c "import sys; print sys.stdout.isatty(); exit(1)" ; echo $?
      True
      1
      
  3. Feb 2021