【发布时间】:2014-08-12 17:59:46
【问题描述】:
我有以下代码。它只是调用 ptrace(PTRACE_TRACEME) 然后进入无限循环。 我有两个问题。
1. after executing this binary, I can't attach gdb even if I am root.
2. with ptrace(PTRACE_TRACEME), I can't terminate the process with Ctrl-C (SIGINT). it simply stops.
谁能解释一下原因?? 先感谢您。 附言。我知道大多数调试器分叉子并调用 ptrace(PTRACE_TRACEME) 'before' execve()。不用提醒我。
#include <sys/ptrace.h>
#include <sys/reg.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
int main(int argc, char **argv) {
printf("my pid : %d\n", getpid());
ptrace(PTRACE_TRACEME);
while(1){
printf("euid : %d\n", geteuid());
sleep(2);
}
return 0;
}
【问题讨论】: