Torsten Bögershausen <tbo...@web.de> writes:
> Thanks for an interesting reading,
> please allow a side question:
> Could it be, that "-1 == unlimited" is Linux specific?
> And therefore not 100% portable ?
> And doesn't "unlimited" number of files call for trouble,
> having the risk to starve the machine ?
> BTW: cygwin returns 256.
If you look at the caller, you will see that we do cap the value
returned from this helper function down to a more reasonable and not
so selfish maximum, exactly for the purpose of avoiding the risk of
starving other processes.
> RETURN VALUE
> If name is an invalid value, sysconf() returns -1 and sets errno to
> indicate the error. If the variable corresponding to name is associated with
> functionality that is not supported by the system, sysconf() returns -1
> without changing the value of errno.
That is a rather dated document. POSIX.1-2013 (look for the URL to
the corresponding page in an earlier message from me) has a bit
tighter wording than that to clarify the "there is no limit" case.
In addition, the final version Peff and I worked out does not even
look at the value of errno, in order not to rely on possibly
ambiguous interpretations of negative return values. So I think we
> ---------- Mac OS, based on BSD (?): ----------
> RETURN VALUES
> If the call to sysconf() is not successful, -1 is returned and errno is
> set appropriately. Otherwise, if the variable is associated with func-
> tionality that is not supported, -1 is returned and errno is not modi-
> fied. Otherwise, the current variable value is returned.
> The sysconf() function may fail and set errno for any of the errors spec-
> ified for the library function sysctl(3). In addition, the following
> error may be reported:
> [EINVAL] The value of the name argument is invalid.
> The sysconf() function first appeared in 4.4BSD.
> Linux, Debian:
> OPEN_MAX - _SC_OPEN_MAX
> The maximum number of files that a process can have open at any
> time. Must not be less than _POSIX_OPEN_MAX (20).
> RETURN VALUE
> If name is invalid, -1 is returned, and errno is set to EINVAL. Other‐
> wise, the value returned is the value of the system resource and errno
> is not changed. In the case of options, a positive value is returned
> if a queried option is available, and -1 if it is not. In the case of
> limits, -1 means that there is no definite limit.
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html