4 Replies Latest reply: Sep 19, 2012 3:35 AM by user9078101 RSS

    Got too many open file on popen but pfiles shows very high limit

    user9078101
      Hi all,

      i'm working on Solaris 10 X86 and got a very strange problem.

      My process failed to run popen because of "Too many oen files". WHile looking at the pfiles output i see that the file descriptors limit is set to 65536, and the number of entries returned by pfiles are around 300.

      Do anybody have an idea about the root cause of the error ?

      Is there a known problem related to thi issue ?

      Any help/idea is welcome.

      Thanks,
      Yaakov
        • 1. Re: Got too many open file on popen but pfiles shows very high limit
          800381
          user9078101 wrote:
          Hi all,

          i'm working on Solaris 10 X86 and got a very strange problem.

          My process failed to run popen because of "Too many oen files". WHile looking at the pfiles output i see that the file descriptors limit is set to 65536, and the number of entries returned by pfiles are around 300.

          Do anybody have an idea about the root cause of the error ?

          Is there a known problem related to thi issue ?

          Any help/idea is welcome.

          Thanks,
          Yaakov
          The standard 32-bit IO library in Solaris limits the maximum number of open FILE structures to 256, because the file descriptor was originally stored in an unsigned char field. Changing that will break existing applications.

          Read this to see what you can do:

          http://developers.sun.com/solaris/articles/stdio_256.html

          You could also compile your code into a 64-bit executable, but that's a lot harder if your developers have done dumb things like assuming that "size_t is always unsigned int", or "pointers are the same size as an int".
          • 2. Re: Got too many open file on popen but pfiles shows very high limit
            user9078101
            Your mail was very helpful and fix my problem.

            What is still not clear for me, is that in the same process i already have about 280 open sockets. As I know sockets are also considered as descriptor.

            So do you have an explanation why only the popen system call failed and not socket creation ?

            Regards,
            Yaakov
            • 3. Re: Got too many open file on popen but pfiles shows very high limit
              800381
              user9078101 wrote:
              Your mail was very helpful and fix my problem.

              What is still not clear for me, is that in the same process i already have about 280 open sockets. As I know sockets are also considered as descriptor.

              So do you have an explanation why only the popen system call failed and not socket creation ?

              Regards,
              Yaakov
              The socket() call returns an int value - your code accesses the file descriptor directly to read or write data. The file descriptor is a 32-bit integer value.

              The popen() fall returns a pointer to a FILE structure, which contains a field used to hold the value of the underlying file descriptor. The library calls used on the FILE structure normally buffer your data - unless you change the buffering (see 'man setbuf') your code does not directly read or write data to the underlying file descriptor. The problem is the old 32-bit FILE structure only uses an 8-bit value to store the file descriptor, which is really a 32-bit integer. So there number of in-use FILE structures is limited in the original 32-bit Sun implementation. But, if Sun and now Oracle were to change the definition of the FILE structure, that would break legacy code that directly accesses fields in the FILE structure.
              • 4. Re: Got too many open file on popen but pfiles shows very high limit
                user9078101
                I got you - Thanks for your explanation.

                Regards.