glibc defines _SC_ATEXIT_MAX, but this is incorrect according to POSIX. If the limit is dependent on an unspecified quantity such as available system memory, POSIX says that the constant shall not be defined.
In any case, the return value INT_MAX of sysconf (_SC_ATEXIT_MAX) is bogus.
It's not entirely clear to me what should be returned or what should be defined.
Are you suggesting we remove _SC_ATEXIT_MAX from limits.h, as the standard suggests, for indeterminate limits?
If that is your suggestion, then we would need some way to verify that we always have 32 atexit slots, since the limit removal is conditional on always meeting the minimum.
32 slot limit is now tested:
I'll mail a patch to delete the _SC_ATEXIT_MAX define.
> what should be returned
If the variable corresponding to name has no limit, sysconf() shall return -1 without changing the value of errno.
I'll send a patch.
This seems to be much bigger problem than just _SC_ATEXIT_MAX:
1. we #define all kinds of other limits: _SC_ARG_MAX, _SC_THREADS, etc.
2. for all of them, we return -1 from getconf (good) while setting errno to ENOSYS (bad).
2. we have no tests for any of this.
As far as I can tell, the names such as _SC_ATEXIT_MAX *should* be defined
unconditionally; it's names such as ATEXIT_MAX that are omitted when the
limits are variable. What's the basis for saying _SC_ATEXIT_MAX should be
(In reply to email@example.com from comment #4)
> As far as I can tell, the names such as _SC_ATEXIT_MAX *should* be defined
> unconditionally; it's names such as ATEXIT_MAX that are omitted when the
> limits are variable. What's the basis for saying _SC_ATEXIT_MAX should be
Yes, your are probably rgiht. I adjusted the summary based on your comment and Paul's in comment 3.
I'll mail a patch soon.