Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Nov 2014 11:07:02 -0800
From:      Dieter BSD <dieterbsd@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Running 8 building 10 gives "Out of file descriptors" ?
Message-ID:  <CAA3ZYrAcCRwb%2B8pWjmeGS9gaE7MS43Jjx17oFkLF8oGJYgCOnw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
        if (fd < 10) {
                fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 10);
                close(fd);
                if (fd2 < 0)
                  {
                    int limit;
                    limit = getdtablesize();
                    fprintf(stderr, "sh: setinputfile(): fcntl() returned %d ge\
tdtablesize() returned %d\n", fd2, limit);
                    perror("sh: fcntl(F_DUPFD_CLOEXEC) failed:");
                        error("sh: Out of file descriptors?");
                  }
                fd = fd2;
        }

Result:
sh: setinputfile(): fcntl() returned -1 getdtablesize() returned 11095
sh: fcntl(F_DUPFD_CLOEXEC) failed:: Invalid argument
sh: Out of file descriptors?

find /usr/include/ | xargs grep F_DUPFD_CLOEXEC
gives no hits in 8.2, but
/usr/include/sys/fcntl.h:
/new/freebsd/usr/include/fcntl.h:
#define    F_DUPFD_CLOEXEC 17         /* Like F_DUPFD, but FD_CLOEXEC is set */
in 10.1

So, F_DUPFD_CLOEXEC was added after 8.2, and someone changed sh to
use it, but couldn't be bothered to fix the error message.

If someone would like to fix this, they don't need to build a toolchain,
they can use a 2 line script:

#!/bin/sh
echo Hello, World!

So Ian, how did you avoid running into this problem?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAA3ZYrAcCRwb%2B8pWjmeGS9gaE7MS43Jjx17oFkLF8oGJYgCOnw>