- /* If there isn't a running nscd we return -1 to indicate that
- * that is precisely what happened
- */
- if (errno == EACCES || errno == ECONNREFUSED || errno == ENOENT)
+ /* If there isn't a running nscd we simulate a "not found"
+ * result and the caller is responsible for calling
+ * fclose on the (unconnected) socket. The value of
+ * errno must be left unchanged in this case. */
+ if (errno == EACCES || errno == ECONNREFUSED || errno == ENOENT) {
+ errno = errno_save;