title: Why does using write() to write date to a disk block the SIGALRM signal until the write finishes?
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;signal.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define BUFSIZE 500*1024*1024
  char buf[BUFSIZE];
  
  static void sig_alrm(int signo) {
      printf("%d\n",time(NULL));
      printf("caught SIGALRM\n");
      fprintf(stderr, "in sig_alrm\n");
  }
  
  
  int main()
  {
      int fd;
      fd=open("a.txt",O_WRONLY);
      signal(SIGALRM,sig_alrm);
      printf("%d\n",time(NULL));
      alarm(1);
      write(fd,buf,BUFSIZE);
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>1414899972
  1414899976
  caught SIGALRM
  in sig_alrm
  </code></pre>
  
  <p>It seems that the SIGALRM was caught about 3 seconds after the call to alarm(1).
  Why isn't the signal caught right away and the system call restarted?</p>