What is special about /dev/tty?

Posted 嗡嘛呢巴美吽舍

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了What is special about /dev/tty?相关的知识,希望对你有一定的参考价值。

ls -la /dev/tty shows the output:

crw-rw-rw- 1 root tty 5, 0 Dec 14 22:21 /dev/tty



The ‘c‘ means it‘s a character device. tty is a special file representing the ‘controlling terminal‘ for the current process.

Character Devices

Unix supports ‘device files‘, which aren‘t really files at all, but file-like access points to hardware devices. A ‘character‘ device is one which is interfaced byte-by-byte (as opposed to buffered IO).

TTY

/dev/tty is a special file, representing the terminal for the current process. So, when you echo 1 > /dev/tty, your message (‘1‘) will appear on your screen. Likewise, when you cat /dev/tty, your subsequent input gets duplicated (until you press Ctrl-C).

/dev/tty doesn‘t ‘contain‘ anything as such, but you can read from it and write to it (for what it‘s worth). I can‘t think of a good use for it, but there are similar files which are very useful for simple IO operations (e.g. /dev/ttyS0 is normally your serial port)

 

 

original from: http://stackoverflow.com/questions/8514735/what-is-special-about-dev-tty

以上是关于What is special about /dev/tty?的主要内容,如果未能解决你的问题,请参考以下文章

什么是极坐标? —— 一点微小的想法 What is Polar Coordinate ? - Some Naive Thoughts about It

about

外刊阅读 Bitcoin Is Plunging

HDU 1075 What Are You Taking About

《What every programmer should know about memory》-What Programmers Can Do译

《What every programmer should know about memory》-What Programmers Can Do译