title: Using signals in C, how to stop and continue a program when timer ends
body: <p>I'm developing a program that runs on a Raspberry-Pi (linux), that gets data from GPS modules and processes it.</p>
  
  <p>Right now, the program is centered around a <code>while(1)</code> loop that takes the GPS data and does stuff with it, (data is streamed at the frequency of the GPS module).</p>
  
  <p>However, I know <code>while(1)</code> is not a very power efficient solution, (This RPi is going to sit on a drone later).</p>
  
  <p>I'd like to set up a timer, and only when the timer ends, will the program take GPS data. Ideally, the program would be completely stopped until the timer ends, so that the CPU is not wasting time/energy on it. </p>
  
  <blockquote>
    <p>How can I do the above mentioned, if <code>SIGSTOP</code> signal is not allowed in <code>sigaction()</code> calls ?</p>
  </blockquote>
  
  <pre><code>void timer_handler(int signum){
      /* what can I do to make a program stop and coninue,
         so that no CPU cycles are devoted to this program until
         the timer is elapsed ? (SIGSTOP is not allowed) */
  }
  
  int main(int argc, char** argv){
  
      struct sigaction sigAct;
      struct itimerval timer;
      sa.sa_handler = &amp;timer_handler;
  
      // SIGALRM is only a place holder here.. 
      sigaction(SIGALRM, &amp;sigAct, NULL);
  
      /* Here would be some timer.it_value, timer.it_interval stuff,
      setting it to some arbitrary time */
  
      setitimer(ITIMER_REAL, &amp;timer, NULL);
  
      /* Main program loop here */
      while(1){
          // process GPS data.
          // instead of while(1), I'd like this loop to run only when
          // the timer ends.
      }
  
  }
  </code></pre>