在 macOS 上/dev/tty. * 和/dev/cu. * 有什么区别?

每个串行设备在 /dev中出现两次,一次是 tty.*,一次是 cu.*

什么是 cu.*设备? 它与 tty.*设备有什么不同?

ls -l /dev/*.usbmodem621

产出:

crw-rw-rw-  1 root  wheel   11,   5 Dec 25 18:00 /dev/cu.usbmodem621
crw-rw-rw-  1 root  wheel   11,   4 Dec 25 18:00 /dev/tty.usbmodem621
53288 次浏览

http://lists.berlios.de/pipermail/gpsd-dev/2005-April/001288.html :

The idea is to supplement software in sharing a line between incoming and outgoing calls. The callin device (typically /dev/tty*) is used for incoming traffic. Any process trying to open it blocks within the open() call as long as DCD is not asserted by hardware (i.e. as long as the modem doesn't have a carrier). During this, the callout device (typically /dev/cu* -- cu stands for "calling unit") can be freely used. Opening /dev/cu* doesn't require DCD to be asserted and succeeds immediately. Once succeeded, the blocked open() on the callin device will be suspended, and cannot even complete when DCD is raised, until the cu device is closed again.

That way, you can have a getty listening on /dev/tty*, and can still use /dev/cu* without restrictions.