首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

ptrace进程跟踪失败解决方法

2012-03-19 
ptrace进程跟踪失败1.首先在终端中运行被跟踪进程test.c:#include stdio.hint main(){while(1){printf(

ptrace进程跟踪失败
1.首先在终端中运行被跟踪进程test.c:
#include <stdio.h>
int main(){
while(1){
printf("pid=%d\n",getpid());
sleep(3);
}
return 0;
}
得到被跟踪进程pid=2127
2.然后运行跟踪进程ptrace_to.c:
#include <stdio.h>
#include <sys/ptrace.h>
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
int main(){
int ret;
ret = ptrace(PTRACE_ATTACH, 2127, 0, 0);
if (ret == -1) {
perror("Failed to ptrace");
}
wait(NULL);
.....
.....
.....
}
3.终端显示:Failed to ptrace:Operation not permitted

为什么会这样啊?知道的能不能给解释下啊?急死我了~~

[解决办法]
看看是不是权限问题呢.

热点排行