$NetBSD: patch-av,v 1.2 2008/08/20 22:17:30 martin Exp $

--- xfermem.c.orig	1999-05-27 20:41:10.000000000 +0200
+++ xfermem.c	2008-08-20 16:04:32.000000000 +0200
@@ -32,8 +32,6 @@
 #include <sys/shm.h>
 #endif
 
-extern int errno;
-
 #if defined (USE_MMAP) && defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
 #define MAP_ANON MAP_ANONYMOUS
 #endif
@@ -180,6 +178,15 @@
 				if (FD_ISSET(fd, &selfds))
 					switch (read(fd, &cmd, 1)) {
 						case 0: /* EOF */
+							/*
+							 * We should not check
+							 * errno later on in
+							 * this case, but we
+							 * have to return an
+							 * error code, so it
+							 * will happen.
+							 */
+							errno = 0;
 							return (-1);
 						case -1:
 							if (errno == EINTR)
