Fix the application, and not adding kernel bloat ?
Then you can also exclude multi-threading, since a thread (even not inside
glibc) can also use socket()/pipe()/open()/whatever and take the zero file
descriptor as well.
Frankly I dont buy this fd namespace stuff.
The only hardcoded thing in Unix is 0, 1 and 2 fds.
People usually take care of these, or should use a Microsoft OS.
POSIX mandates that open() returns the lowest available fd.
But this obviously works only if you dont have another thread messing with
fds, or if you dont call a library function that opens a file.
Thats all.
Quite buggy IMHO
This hack was to avoid bugs coming from ancestors applications,
forking/execing a shell, and at times where one process could not open more
than 20 files (AT&T Unix, 21 years ago)
Unix has fcntl(fd, F_SETFD, FD_CLOEXEC). A library should use this to make
sure fd is not propagated at exec() time.
poll() is nice. Even AT&T Unix had it 21 years ago :)
Please dont do that. Second class fds.
Then what about having ten different shared libraries ? Third class fds ?
-