0

Take a serial port. A serial port can call ioctl with TIOCMIWAIT to wait for a signal change. However if the serial port is open as non-blocking, how does one use something like select, poll or epoll to break out of an event-loop when a signal line like CTS changes? Lets assume that the serial port is also used heavily for reading and writing. Spawning another thread seems like a bad option.

On Windows, OVERLAPPED IO solves this problem perfectly.

I am interested in the specific case listed above but also how to approach writing device drivers that need to pass an interrupt to user space.

doron
  • 27,972
  • 12
  • 65
  • 103
  • As far as I can tell, such a mechanism does not exist. I have spent quite a while looking for one. I'm on the verge of designing and documenting a `TIOCMNOTIFY` call which registers interest for later notification via `poll`() et.al. Though I've no idea how to argue that into Linux kernel... :/ – LeoNerd Jul 02 '19 at 15:24

1 Answers1

0

I think you may want to look at using pselect(). It's the same as select() but it also allows you to set a signal mask. An example of how to use pselect can be found in the top answer here:

catching signals while reading from pipe with select()

hermit
  • 56
  • 6