title: system call return values and errno
body: <p>I am using following system calls in my program:</p>
  
  <pre><code>recvfrom
  sendto
  sendmsg
  </code></pre>
  
  <p>And from each system call mentioned above I check if it completes with out any interruption and in case if it is interrupted, I retry.</p>
  
  <p>Ex:</p>
  
  <pre><code>recvagain:     
      len = recvfrom(fd, response, MSGSIZE, MSG_WAITALL, (struct sockaddr *)&amp;from, &amp;fromlen);
      if (errno == EINTR) {
             syslog(LOG_NOTICE, "recvfrom interrupted: %s", strerror(errno));
             goto recvagain;
      }
  </code></pre>
  
  <p>Problem here is that do I need to reset errno value to 0 each and every time it fails. Or if recvfrom() is successful, does it reset errno to 0?</p>
  
  <p>recvfrom() man page says:</p>
  
  <blockquote>
    <p>Upon successful completion, recvfrom() returns the length of the message in bytes. If no messages are available to be received and the
    peer has performed an orderly shutdown, recvfrom() returns 0.
    Otherwise the function returns -1 and sets errno to indicate the
    error.</p>
  </blockquote>
  
  <p>same case with sendto and sendmsg.</p>
  
  <p>I can n't really check this now as I don't have access to server-client setup.
  Any idea?</p>
  
  <p>Thanks</p>