我有php进程,超过2天无法完成.
root 26511 0.0 1.6 407788 27684 ? Ss Jul09 0:08 /usr/bin/php action.php
这是strace命令的输出:
poll([{fd=7,events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}],1,1000) = 0 (Timeout) poll([{fd=7,0) = 0 (Timeout) clock_gettime(CLOCK_MONOTONIC,{5533745,664851437}) = 0 clock_gettime(CLOCK_MONOTONIC,664940247}) = 0 clock_gettime(CLOCK_MONOTONIC,665211013}) = 0 poll([{fd=7,{5533746,666594416}) = 0 clock_gettime(CLOCK_MONOTONIC,666684149}) = 0 clock_gettime(CLOCK_MONOTONIC,666772214}) = 0 poll([{fd=7,{5533747,668356163}) = 0 clock_gettime(CLOCK_MONOTONIC,668447565}) = 0 clock_gettime(CLOCK_MONOTONIC,668538577}) = 0
你能解释一下这个输出是什么意思吗?或者也许我可以使用其他命令获得有关堆栈进程的更多信息.
PHP版本:PHP 5.4.30
CentOS发布6.5
解决方法
strace命令列出应用程序在运行时进行的系统调用.
如果您不是开发人员:系统手册的第2部分系统调用帮助您了解正在发生的事情.
man 2 poll
DESCRIPTION poll() performs a similar task to select(2): it waits for one of a set of file descriptors to become ready to perform I/O.
轮询系统调用中请求的事件都与文件描述符7相关,再次从手册页中查看应用程序请求的事件:
POLLIN There is data to read. POLLPRI There is urgent data to read. POLLRDNORM Equivalent to POLLIN. POLLRDBAND Priority band data can be read (generally unused on Linux).
strace行显示轮询操作超时,文件描述符(#7)没有为读取IO做好准备.
系统调用clock_gettime() – 时钟和时间函数表示等待一段时间,然后再试一次.
要找出导致超时的文件,应该有数字7的符号链接,表示/ proc /< PID> / fd / 7中文件的整数