开发者

what is "tty" on FreeBSD?

"uprintf() function ou开发者_如何学编程tputs to the current process' controlling tty"

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


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...

what is "tty" on FreeBSD?

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

what is "tty" on FreeBSD?

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...


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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜