/dev/tty is a synonym for the controlling terminal that is associated with the process group of the current process. /dev/tty is particularly useful to make sure that messages are written or read from that terminal, no matter how input or output is redirected. stty os has a ctermid() method which returns the filename of the controlling process's terminal.