I am reading Linux System Programming by Robert Love and trying to understand the concept of file descriptors.
He mentions that
File descriptors start at 0 and go up to one less than this maximum value. By default, the maximum is 1,024
So, for example, I have two files open using the file descriptors 500 and 501 respectively.
Now if the file with file descriptor 500 is closed does that mean that the next fd to be allocated will be 502? Can it reuse 500? If so how can it do that, does the kernel maintain all closed file descriptors?