title: How to handle EINTR (interrupted System Call)
body: <p>My user-space application sometimes blocks after receiving an EINTR-Signal, somehow. </p>
  
  <p>What I recorded with strace: </p>
  
  <pre><code>time(NULL)                              = 1257343042
  time(NULL)                              = 1257343042
  rt_sigreturn(0xbff07be4)                = -1 EINTR (Interrupted system call)
  --- SIGALRM (Alarm clock) @ 0 (0) ---
  time(NULL)                              = 1257343042
  futex(0xb7cea80c, 0x80 /* FUTEX_??? */, 2) = ? ERESTARTSYS (To be restarted)
  --- SIGUSR1 (User defined signal 1) @ 0 (0) ---
  sigreturn()                             = ? (mask now [ALRM])
  futex(0xb7cea80c, 0x80 /* FUTEX_??? */, 2) = ? ERESTARTSYS (To be restarted)
  --- SIGWINCH (Window changed) @ 0 (0) ---
  futex(0xb7cea80c, 0x80 /* FUTEX_??? */, 2) = ? ERESTARTSYS (To be restarted)
  --- SIGTERM (Terminated) @ 0 (0) ---
  time(NULL)                              = 1257343443
  time(NULL)                              = 1257343443
  futex(0xb7cea80c, 0x80 /* FUTEX_??? */, 2) = ? ERESTARTSYS (To be restarted)
  --- SIGWINCH (Window changed) @ 0 (0) ---
  futex(0xb7cea80c, 0x80 /* FUTEX_??? */, 2
  </code></pre>
  
  <p>Can I catch the EINTR signal and how can I repeat concerned calls such as write, read or select? How can I determine WHERE this EINTR occurred, even if I used third-party libraries working with system calls?</p>
  
  <p>Why my app is completely blocked after receiving an EINTR (see strace dump: I sent a SIGUSR1 which normally should be handled)? And why is futex() returning ERESTARTSYS to user space?</p>
  
  <p>thanks</p>