title: Implementing sleep() using SIGALRM
body: <p>I have tried to replace sleep() by SIGALRM.</p>
  
  <pre><code>#include &lt;signal.h&gt; 
  #include &lt;unistd.h&gt;
  
  void sig_alrm( int signo )
  {
      return; /* return to wake up pause */
  }
  
  unsigned int sleep1( unsigned int nsecs )
  {
      if( signal( SIGALRM, sig_alrm ) == SIG_ERR )
          return (nsecs);
      alarm( nsecs ); /* starts timer */
      pause(); /* next caught signal wakes */
      return( alarm( 0 ) ); /* turn off timer, return unslept*/
  }
  </code></pre>
  
  <p>Is this correct implementation?
  Is there another implementation?</p>