File descriptor, FD?
When each program opens a file, the system returns a file descriptor, which the program needs to reference in order to process the file, referred to as FD. FD is an integer, starting with 0, where 0 is the standard input, and 1 and 2 are standard output and standard error output, respectively. printf, for example, uses stdout by default. FD is a process-per-process unit with a maximum number of FD, which can be set using the Ulimit.
When a process attempts to open a new file by using an open function, the kernel open finds a collection of file descriptors for the current process, looks at whether the allocated file descriptor exceeds the maximum value of the process, and if the maximum value is not exceeded, assigns an FD to the process and then processes the file's read/ Write functions can refer to this file descriptor.
Similarly, in the open function, the total number of FD in the system is also checked for more than the setting in File-max, and if the maximum limit is exceeded, open fails.
How do I change the maximum number of FD limits for the system?
1) The system maximum value of FD is in/proc/sys/fs/file-max.
2) The maximum number of processes FD is set in Ulimit.
System maximum FD number and maximum FD number in process