title: How to efficiently wait for CTS or DSR of RS232 in Linux?
body: <p>Currently, I'm reading the CTS and DSR signals of a serial port in the following way:</p>
  
  <pre><code>bool get_cts(int fd) {
      int s;
      ioctl(fd, TIOCMGET, &amp;s);
      return (s &amp; TIOCM_CTS) != 0;
  }
  </code></pre>
  
  <p>Now I'd like to wait until <code>get_cts()</code> returns true. A simple loop isn't the best solution I think (as it's extremely resource-intensive).</p>
  
  <pre><code>void wait_cts(int fd) {
      while(1) {
          if(get_cts(fd)) {
               return;
          }
      }
  }
  </code></pre>
  
  <p>Is there any better solution using C or C++ on Linux? (I cannot use any hardware flow control as I don't need the serial data lines at all.)</p>