stdio is currently limited to file descriptors not greater than
{SHRT_MAX}, so {STREAM_MAX} should be no greater than that. (This does not exactly meet the letter of POSIX but comes reasonably close to it in spirit.) MFC after: 14 days
This commit is contained in:
parent
bcd067ff4f
commit
e043fbfcde
@ -100,7 +100,6 @@ sysconf(name)
|
||||
mib[1] = KERN_NGROUPS;
|
||||
break;
|
||||
case _SC_OPEN_MAX:
|
||||
case _SC_STREAM_MAX: /* assume fds run out before memory does */
|
||||
if (getrlimit(RLIMIT_NOFILE, &rl) != 0)
|
||||
return (-1);
|
||||
if (rl.rlim_cur == RLIM_INFINITY)
|
||||
@ -109,6 +108,25 @@ sysconf(name)
|
||||
errno = EOVERFLOW;
|
||||
return (-1);
|
||||
}
|
||||
return ((long)rl.rlim_cur);
|
||||
case _SC_STREAM_MAX:
|
||||
if (getrlimit(RLIMIT_NOFILE, &rl) != 0)
|
||||
return (-1);
|
||||
if (rl.rlim_cur == RLIM_INFINITY)
|
||||
return (-1);
|
||||
if (rl.rlim_cur > LONG_MAX) {
|
||||
errno = EOVERFLOW;
|
||||
return (-1);
|
||||
}
|
||||
/*
|
||||
* struct __sFILE currently has a limitation that
|
||||
* file descriptors must fit in a signed short.
|
||||
* This doesn't precisely capture the letter of POSIX
|
||||
* but approximates the spirit.
|
||||
*/
|
||||
if (rl.rlim_cur > SHRT_MAX)
|
||||
return (SHRT_MAX);
|
||||
|
||||
return ((long)rl.rlim_cur);
|
||||
case _SC_JOB_CONTROL:
|
||||
return (_POSIX_JOB_CONTROL);
|
||||
|
Loading…
Reference in New Issue
Block a user