Linux: 一切皆文件; peekfd: 偷看一切文件读写
· ☕ 3 分钟
Linux 大部分数据流动,包括进程间通讯,socket…… 均通过文件描述符(fd) 读写实现。在 troubleshooting 时,如果可以偷看到 fd 的流量,那么很多问题可以加速证明/证伪。本文介绍一个老工具 peekfd ,可以在一定环境中完成这个任务。
程序员有两个世界:
It is a capital mistake to theorize before one has data. Insensibly one begins to twist facts to suit theories, instead of theories to suit facts.
|
|
|
|
然后在另外一个终端中
|
|
可以看到在 bpftrace 终端中输出: