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.
Examples use a (spinlock?) for (;;) e.g.
int main()
{
    // register interrupt
    wiringPiISR( 18, INT_EDGE_BOTH, &myInterrupt );
    for (;;) {
        // really?
    }
    return 0;
}
And I noticed that sleep works too. The interrupt is called regardless of the sleep
int main() 
{
    // register interrupt
    wiringPiISR( 18, INT_EDGE_BOTH, &myInterrupt );
    for (;;) {
        sleep(1000000);
    }
    return 0;
}
What is the best practise to keep the program running, using minimal resources (say if this were for a background demon)?
Coming from other languages, I would have thought for(;;) would eat up resources. I would like to know what to do or pointers on what to do (threads etc).
 
     
     
     
     
     
     
    