Linux 轮询系统调用超时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13018981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:40:47  来源:igfitidea点击:

poll system call timeout

linuxsystem-callsstrace

提问by mahmood

Attaching straceshows a lot of these messages:

附件strace显示了很多这样的消息:

poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=9, events=POLLIN}, {fd=10, events=POLLIN}], 6, 0) = 0 (Timeout)

poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=9, events=POLLIN}, {fd=10, events=POLLIN}], 6, 0) = 0 (Timeout)

poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=9, events=POLLIN}, {fd=10, events=POLLIN}], 6, 0) = 0 (Timeout)

poll([{fd=5, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=9, events=POLLIN}, {fd=10, events=POLLIN}], 6, 0) = 0 (Timeout)

How can I find what file the program is trying to access that causes pollsystem call to timeout?

如何找到程序试图访问导致poll系统调用超时的文件?

stracegenerates a lot of messages which make it hard to debug

strace生成大量消息,使调试变得困难

回答by Maxim Egorushkin

How can I find what file the program is trying to access that causes poll system call to timeout?

如何找到程序试图访问导致轮询系统调用超时的文件?

Invoke:

调用:

lsof -p <pid>

And see what the file descriptors in question refer to.

并查看有问题的文件描述符指的是什么。

You can also take a look into procfilesystem on Linux:

您还可以查看procLinux 上的文件系统:

ls -l /proc/<pid>/fd

回答by Kamel Haddad

ls -l /proc//fd/ -> You will get the corresponding node Id. ss -p | grep -> you will get the socket file path the fd belongs to.

ls -l /proc//fd/ -> 你会得到对应的节点Id。ss -p | grep -> 您将获得 fd 所属的套接字文件路径。