title: OpenSSL and signals
body: <p>Socket functions like <code>send</code> and <code>receive</code> can be interrupted by signals. Because of this some extra code is needed, e.g. to check for <code>errno == EINTR</code>. This is described on corresponding man pages.</p>
  
  <p>I wonder how this works when OpenSSL functions are used, e.g. <code>SSL_write</code>, <code>SSL_read</code>. Their man pages do not say anything about signals. I also tried to google for this, but without luck. Do you know if OpenSSL handles signals internally, or some extra code is needed? If yes, how to check if function call was interrupted by signal?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Looks that OpenSSL does not handle retries. It only sets the "should retry" flag on BIO object. So I need to use something like this to detect if call was interrupted and retry is needed:</p>
  
  <pre><code>int result = SSL_write(ssl, buff, length);
  if ((result &lt; 0) &amp;&amp; BIO_should_retry(SSL_get_wbio(ssl)))
      // need to retry
  
  int result = SSL_read(ssl, buff, length);
  if ((result &lt; 0) &amp;&amp; BIO_should_retry(SSL_get_rbio(ssl)))
      // need to retry
  </code></pre>