core: Restore get_max_fds optimization on Linux
* src/posix-io.c (get_max_fds): Restore Linux optimization, this time using open/getdents/close rather than opendir/readdir/closedir.
opendir/readdir/closedir may allocate/free memory, and aren't required
to do so in an async-signal-safe way. On the other hand, opening
/proc/self/fd directly and iterating over it using getdents is safe.
(getdents is not strictly speaking documented to be async-signal-safe
because it's not in POSIX. However, the Linux implementation is
essentially just a souped-up read. Python >= 3.2.3 makes the same
assumption.)
- Signed-off-by: Colin Watson <cjwatson@debian.org>