文件句柄: A file handle is a pointer to an actual data structure
文件描述符: A file descriptor is a just an abstract key for accessing the file
因此,文件句柄和文件描述符是不一样的。
相关函数简介
函数getdtablesize,获取文件描述符表格的大小。
1 2 3 4 5 6 7 8
getdtablesize() returns the maximum number of files a process can have open, one more than the largest possible value for a file descriptor. 系统调用如下: SYSCALL_DEFINE0(getdtablesize) { return sysctl_nr_open; }
# cat /proc/self/limits Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited seconds Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core file size unlimited unlimited bytes Max resident set unlimited unlimited bytes Max processes 1048576 1048576 processes
Max open files 64000 64000 files
Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 10546 10546 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us