When closefrom is not available, it uses get_max_fds.
get_max_fds implementation has following issues:
- return type mismatch: int is good
- TRACE may calls non-async-signal-safe function, may result hang (in multithread application)
- sysconf is not async-signal-safe function, may result hang (in multithread application)
- syscall return type is long. For 64-bit arch, it has unseen type conversion from long to int, which is difficult to read. Use of long for r and pos is good.
- On a machine which doesn't allow unaligned access, dir_buf should be aligned properly (__attribute__ ((aligned (8))). getdents64 itself would be OK for the kernel (glibc documentation seems to say so) with unaligned buf, but dir_entry->d_reclen is not.