todayhero 发表于 2013-05-15 10:49

strace分析php-fpm进程问题

strace -p PID分析php-fpm进程

at("/data/tdocs/webroot/go/./Widget/boutique.inc.php", 0x7fffc74cb320) = -1 ENOENT (No such file or directory)
lstat("/data/tdocs/webroot/go/./Widget/openapi.inc.php", 0x7fffc74cb320) = -1 ENOENT (No such file or directory)
lstat("/data/tdocs/webroot/go/./Widget/groupnew.inc.php", 0x7fffc74cb320) = -1 ENOENT (No such file or directory)
lstat("/data/tdocs/webroot/go/./Widget/groupStatistical.inc.php", 0x7fffc74cb320) = -1 ENOENT (No such file or directory)
lstat("/usr/share/pear/Widget/groupStatistical.inc.php", 0x7fffc74cb320) = -1 ENOENT (No such file or directory)
lstat("/usr/share/php/Widget/groupStatistical.inc.php", 0x7fffc74cb320) = -1 ENOENT (No such file or directory)

怎么找不到文件呢?这是程序员写的程序有问题吗?


hwrd_et 发表于 2013-05-15 11:52

本帖最后由 hwrd_et 于 2013-05-15 11:53 编辑

不是的,如果我在程序里用file_exists($file)来判断文件存不存在,如果这个文件不存在,你strace里就会显示这种情况,其实PHP代码没有错

todayhero 发表于 2013-05-15 12:27

@hwrd_et

但是我的程序并没有判断上面没有的文件是不是存在了。

hwrd_et 发表于 2013-05-15 12:53

todayhero 发表于 2013-05-15 12:27 static/image/common/back.gif
@hwrd_et

但是我的程序并没有判断上面没有的文件是不是存在了。

那就是你include文件的时候没使用绝对路径(include '/a.php')或者相对路径(include './a.php'),你直接使用了include 'a.php',这种情况的话,先从当前目录找到文件存不存在,然后再从include_path查看文件存不存在。

我这些都是打个比方,strace的提示,确实是PHP在找这个文件,没找到,但并不是说PHP代码就有问题

linux_c_py_php 发表于 2013-05-16 17:01

是在PHP的各个路径下尝试查找, 有一个成功就可以了.

bikong0411 发表于 2013-05-17 09:02

不写绝对路径就是按照php的include_path进行一个一个尝试直到找到为止

maochanglu 发表于 2013-05-20 09:08

先判断存在,再 包含, 比较靠谱些
页: [1]
查看完整版本: strace分析php-fpm进程问题