title: Efficient way to wait for an interrupt in C
body: <p>I am using WiringPi on a raspberry pi. With it I assign an interrupt function which is called later. I'm not sure what to do when waiting for the interupt to be called. </p>
  
  <p>Examples use a (spinlock?) <code>for (;;)</code> e.g.</p>
  
  <pre><code>int main()
  {
      // register interrupt
      wiringPiISR( 18, INT_EDGE_BOTH, &amp;myInterrupt );
  
      for (;;) {
          // really?
      }
      return 0;
  }
  </code></pre>
  
  <p>And I noticed that <code>sleep</code> works too. The interrupt is called regardless of the sleep</p>
  
  <pre><code>int main() 
  {
      // register interrupt
      wiringPiISR( 18, INT_EDGE_BOTH, &amp;myInterrupt );
  
      for (;;) {
          sleep(1000000);
      }
      return 0;
  }
  </code></pre>
  
  <p>What is the best practise to keep the program running, using minimal resources (say if this were for a background demon)?</p>
  
  <p>Coming from other languages, I would have thought <code>for(;;)</code> would eat up resources. I would like to know what to do or pointers on what to do (threads etc).</p>