OpenSolaris

Printable Version Enter a New Search
Bug ID 1085341
Synopsis 32-bit stdio routines should support file descriptors >255
State 10-Fix Delivered (Fix available in build)
Category:Subcategory library:libc
Keywords _file | long | netbeans | stdio.h | unsigned
Responsible Engineer Craig Mohrman
Reported Against 2.6 , 5.4 , 5.5 , 5.6 , 5.7 , 5.8 , b68 , dev , 1.03 , 5.5.1 , s1093 , s10_52 , s494_fcs , 5.0prebeta3.0
Duplicate Of
Introduced In solaris_2.0
Commit to Fix snv_39
Fixed In snv_39
Release Fixed solaris_nevada(snv_39) , solaris_10u4(s10u4_04) (Bug ID:2143991)
Related Bugs 6259671 , 6287034 , 1147964 , 1164914 , 1173088 , 1212385 , 4008346 , 4050822 , 4125638 , 4134735 , 6367536 , 6367565 , 4239433 , 4270357 , 6375138 , 4400631 , 4406529 , 6376832 , 4504326 , 4619504 , 6386770 , 4722995 , 4751029 , 4843145 , 4960267 , 4985961 , 6414401 , 6416815 , 6417483 , 6425274 , 6426756 , 6431278 , 6522794 , 6533291 , 6550660 , 6579640 , 6774698 , 4916205 , 6190525 , 6234782
Submit Date 4-March-1992
Last Update Date 15-February-2007
Description
Currently, _file in /usr/include/stdio.h is declared as an 
	unsigned char, which limits the number of file descriptors
	per process to 256 (2^8 = 256).  ISV's such as Sybase need
	to have that limit increased to 2048 for user connections
	to their database server.  Therefore, _file should be de-
	clared as an unsigned long instead of an unsigned char.

The description field as copied from bug report 1212385 follows:

Although the limit for file descriptors is 1024, you cannot open more than 256 fd's
using stdio.h. _file is declared as an unsigned char in /usr/include/stdio.h which
restricts the access to file descriptors to 256.

Reproduce by compiling and running the following program:

#include <stdio.h>

main()
{
       	FILE *fd;
       	int i;
       	char buf[10];

       	printf("Could not open ");
       	for(i=3; i < 1024; i++)
       	{
                sprintf(buf, "xx%d", i);
                fd = fopen(buf, "w"); 
                if (fd <= (FILE *)0)
                {
                       	printf("%d ",i);
                }
       	}
       	printf("\\n");
}



1) Documentation bug: man page for fopen() needs to directly acknowledge its
limitation to file descriptors 0-255 or at least direct the user to the stdio
man page for information about limitations.

2) Code bug: fopen() provides no identification of error when it hits the
above limitation:
errono is set to 0 when fopen() fails.
Work Around
N/A
Comments
N/A