How can I detect when someone opens the slave side of a pty (pseudo-terminal) in Linux?

后端 未结 2 1101
悲&欢浪女
悲&欢浪女 2020-12-09 12:10

Having more than one process read from a serial device (/dev/ttyXX) makes it so that both processes can\'t get all of the data -- the data will be split between them in some

2条回答
  •  無奈伤痛
    2020-12-09 12:59

    Add an inotify watch on the slave pty and poll on that. You can get an inotify event on open. You can then poll on the inotify file descriptor and the master pty file descriptor. You can get an inotify event for open (IN_OPEN). This will unblock the poll when the slave side is opened.

提交回复
热议问题