set EMFILE if out of fd's
authorJay Lepreau <lepreau@ucbvax.Berkeley.EDU>
Thu, 19 Sep 1985 14:44:32 +0000 (06:44 -0800)
committerJay Lepreau <lepreau@ucbvax.Berkeley.EDU>
Thu, 19 Sep 1985 14:44:32 +0000 (06:44 -0800)
SCCS-vsn: lib/libc/stdio/findfp.c 5.2

usr/src/lib/libc/stdio/findfp.c

index b36d159..e5a8e24 100644 (file)
@@ -5,10 +5,13 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)findfp.c   5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)findfp.c   5.2 (Berkeley) %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
+#include <errno.h>
+
+extern int errno;
 
 #define active(iop)    ((iop)->_flag & (_IOREAD|_IOWRT|_IORW))
 
 
 #define active(iop)    ((iop)->_flag & (_IOREAD|_IOWRT|_IORW))
 
@@ -51,8 +54,10 @@ _findiop()
 
        iov = iobglue;
        while (*iov != NULL && active(*iov))
 
        iov = iobglue;
        while (*iov != NULL && active(*iov))
-               if (++iov >= endglue)
+               if (++iov >= endglue) {
+                       errno = EMFILE;
                        return (NULL);
                        return (NULL);
+               }
 
        if (*iov == NULL)
                *iov = (FILE *)calloc(1, sizeof **iov);
 
        if (*iov == NULL)
                *iov = (FILE *)calloc(1, sizeof **iov);