what is “tty” on FreeBSD?

只愿长相守 提交于 2021-02-06 13:50:36

问题


"uprintf() function outputs to the current process' controlling tty"

This is description of uprintf() from Freebsd MAN. I don't understand what is tty? Thanks.Nice holiday!


回答1:


A tty is an abstract model of a character I/O device. It is most directly a system interface, with corresponding application program interfaces.

Once upon a time there was a corporation named Teletype. They made hardcopy automatic typewriter devices that were used as communications terminals for decades and then repurposed as hardcopy computer terminals. Teletype was generalized to teletypewriter or teleprinter in order to avoid using a brand name.

Originally they were functional but rather ugly...

alt text

But later models (this model 43 is from the late 1970's) were quite beautiful...

alt text

The microprocessor made video display terminals practical, previously, the hard copy terminals were quite a bit cheaper and vastly more popular. As it happens, the Unix tty abstraction worked great for video terminals as well.

And, it worked just fine for xterm windows, and xterm's children (usually called Terminal) that will be found on Linux, Mac, and other descendants of Unix...




回答2:


The concept of 'controlling tty' has a modern meaning, but the word 'tty' is a very old concept. tty = teletype, and it's how people used to communicate with computers. The concept of 'tty' in the FreeBSD man page is referring to the device that is accepting user input for the program.

Now, windows and such are accepting user input too. But that's not what a 'tty' refers to exactly. Only certain windows have a tty associated with them. Generally, for example, most shell windows. In that case the tty is known as a psuedo-terminal, and is also called a 'pty'. It's a 'pseudo' terminal because it isn't associated with a specific device. In fact, it's controlled by a program that's pretending to be a terminal. In the case of a window, the program that displays the window.

In Unices, a tty has a special role in a program. Most processes have a 'controlling tty' or 'controlling terminal'. This tty is allowed to send them certain kinds of signals, regardless of what privileges the process has. For example, SIGTSTP.




回答3:


According to Wikipedia, the name comes from teletypewriter, abbreviated “TTY”. Printing directly to the tty means that it prints a message directly to the console, even if STDOUT has been redirected to a file or another process.




回答4:


Actually is the name of your current input device from your system... in most cases your keyboard.

mac-user:~$ tty
    /dev/ttys001

this means that your keyboard is the device ttys001



来源:https://stackoverflow.com/questions/4532413/what-is-tty-on-freebsd

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!