本文共 3486 字,大约阅读时间需要 11 分钟。
如果你希望看到C语言级别的php代码就需要使用strace这个默认是安装了的,如果没有安装可以
#yum install strace
查看httpd进程
#ps auxw | grep httpd
有多个,必须停止apache
[root@localhost usr]# /usr/local/webserver/apache2/bin/apachectl stop
启动单进程httpd
[root@localhost usr]# /usr/local/webserver/apache2/bin/apachectl -X -k start
再使用#ps auxw | grep httpd查看只有单经常,记下进程id
将strace绑定至apache
#strace -p 28224
算法
快速排序php代码
'; print_r(quickSort($arr)); ?>
在浏览器请求php页面,得到追踪信息
注意:如果看C语言生成的文件直接strace即可
#strace ./a.out
如果你只要看php的opcode可以参考:
最简单的php代码
$a='123';
echo $a;追踪输出:
我们清晰的看到完整的解析流程
从eAccelerator中去读取缓存:
调用open()函数打开文件-->flock()函数锁定文件-->read()函数读取文件内容-->flock()解除锁定-->close()关闭文件
writev()输出http协议头http/1.1 200等等
关于eAccelerator参考
----------------------------------------------------
flock() 函数 锁定文件或解除锁定
==============================
通用函数
gettimeofday取得目前的时间
gettimeofday()会把目前的时间有tv所指的结构返回, 当地时区的信息则放到tz所指的结构中。
timeval结构定义为:struct timeval{ long tv_sec; /*秒*/long tv_usec; /*微秒*/};timezone 结构定义为:struct timezone{ int tz_minuteswest; /*和Greenwich 时间差了多少分钟*/int tz_dsttime; /*日光节约时间的状态*/};#include#include main(){ struct timeval tv; struct timezone tz; gettimeofday (&tv , &tz); printf("tv_sec; %d\n", tv,.tv_sec) ; printf("tv_usec; %d\n",tv.tv_usec); printf("tz_minuteswest; %d\n", tz.tz_minuteswest); printf("tz_dsttime, %d\n",tz.tz_dsttime);}
=======================================================================
poll 函数
http://linux.about.com/library/cmd/blcmdl2_poll.htm
Linux / Unix Command: poll
NAME
poll - wait for some event on a file descriptorSYNOPSIS
#include <sys/poll.h>int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
DESCRIPTION
pollis a variation on the theme of select. It specifies an array of nfdsstructures of typestruct pollfd { int fd; /* file descriptor */ short events; /* requested events */ short revents; /* returned events */ };-------------------------
write 将数据写入已打开的文件内
Linux / Unix Command: writev
http://linux.about.com/library/cmd/blcmdl2_writev.htm
NAME
readv, writev - read or write a vectorSYNOPSIS
#include <sys/uio.h>ssize_t readv(int fd, const struct iovec *vector, int count);ssize_t writev(int fd, const struct iovec *vector, int count);
struct iovec { void *iov_base; /* Starting address */ size_t iov_len; /* Length in bytes */};----------------------------
使用man命令查getsockname
其他函数:
取得用户标识
获取当前目录
检查和改变信号动作,sigaction() 系统调用被用于更改一个进程在接收一个特定信号后的动作。
获取设置定时器的值
在文件描述符上等待事件
获取文件状态
改变工作目录
转载地址:https://linuxstyle.blog.csdn.net/article/details/8195119 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!