当前位置:网站首页>Fd: file descriptor
Fd: file descriptor
2022-06-21 08:13:00 【Fly&L】
FD Introduce
file descriptors (FD) File descriptor , File handle .Linux The system treats everything as a file , When the process opens an existing file or creates a new file , The kernel returns a file descriptor to the process , File descriptors are indexes created by the kernel to efficiently manage opened files , Used to point to an open file , All execution I/O The system call of the operation will pass through the file descriptor .
FD The role of : Processes use file descriptors to manage open files , programmatic FD Is the symbol of the document ( Link to the file ), Eliminate the long and absolute path .
0 Is keyboard read only
1,2 A terminal can be understood as a screen
3+ It's a document , Can read but write

How to understand /proc The directory under the file ?
The so-called process , It is the data only available when the machine is running , That is, all in memory . The data in the memory is written to /proc/* Under this catalog .
/proc Catalog understanding
# testing tail Of pid
┌──(rootkali)-[/proc]
└─# ps -aux | grep tail
root 4387 0.0 0.0 5800 568 pts/0 S+ 11:33 0:00 tail -f stat
root 4424 0.0 0.0 6408 648 pts/1 S+ 11:36 0:00 grep --color=auto tail
# View the limits of the process , stay Max open files You can see that a process can create at most fd The quantity of is 1024
┌──(rootkali)-[/proc]
└─# cat /proc/4387/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 0 unlimited bytes
Max resident set unlimited unlimited bytes
Max processes 7647 7647 processes
Max open files 1024 1048576 files
Max locked memory 260805632 260805632 bytes
Max address space unlimited unlimited bytes
Max file locks unlimited unlimited locks
Max pending signals 7647 7647 signals
Max msgqueue size 819200 819200 bytes
Max nice priority 0 0
Max realtime priority 0 0
Max realtime timeout unlimited unlimited us
# The process takes up 17 A descriptor
┌──(rootkali)-[/proc]
└─# cat /proc/4387/limits | wc -l
17
View the number of open file descriptors used by the current system
┌──(rootkali)-[/proc]
└─# cat /proc/sys/fs/file-nr
5792 0 9223372036854775807
# The first number indicates the number of open file descriptors allocated by the system , The second one is no longer used , The third term is file-max
The most open processes fd
see :ulimit -n
Temporary settings : ulimit -n 10000
FD And handle
Check the article
In depth understanding of FD
边栏推荐
- Bean实例化的三种方法
- (对于换行符)gets和fgets的区别,puts和fputs的区别
- 图解 Google V8 # 14:字节码(二):解释器是如何解释执行字节码的?
- /home/ljx/miniconda3/compiler_compat/ld: cannot find crtbeginS.o: 没有那个文件或目录
- Classic topics of leetcode array (I)
- Wanzi detailed data warehouse, data lake, data middle platform and lake warehouse are integrated
- (greedy) B. avoid local maximums
- Global and Chinese market of electrical connectors 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese market for crankshaft position sensors 2022-2028: Research Report on technology, participants, trends, market size and share
- 文件下载 二进制流的形式构造url和base64下载
猜你喜欢

2021-06-18 STM32F103 DMA 与 DMA串口代码 使用固件库

2022-2028 global after sales spark plug industry research and trend analysis report

Figure neural network and cognitive reasoning - Tang Jie - Tsinghua University

Antique typesetting (20 points) (test point 4)

Diary (C language summary)

Markdown rule for writing articles

Linux Installation of Damon database /dm8 (with client tool installation full version)

2021-07-28 STM32F103配置信息

Mongodb installation (Graphic tutorial)

怎么搭建深度学习框架?
随机推荐
Mongodb installation (Graphic tutorial)
虚拟机浏览器花屏空白问题
JVM memory model concepts
微信公众号对接 : 一键推送文章信息至公众号
Markdown rule for writing articles
1004 counting leaves (30 points)
怎么搭建深度学习框架?
Bean实例化的三种方法
[redis]-[redis underlying data structure]-sds
【kotlin】第一天
Construct URL and Base64 download in the form of binary stream for file download
CTF show WEB10
/home/ljx/miniconda3/compiler_compat/ld: cannot find crtbeginS.o: 没有那个文件或目录
Three declaration methods of structure type
為什呢代碼沒報錯但是數據庫裏邊的數據顯示不出來
图解 Google V8 # 14:字节码(二):解释器是如何解释执行字节码的?
How can we make millions a year now?
RISC-V 的MMU
2021-07-28 STM32F103 I2C Hardware Transfer Include previous IO Clock EXIT USB use firmware library
Vision_ Transformer code exercise