Chinaunix
标题:
为啥PTRACE_DETACH后进程状态还是traced?
[打印本页]
作者:
rootclown
时间:
2007-01-05 13:32
标题:
为啥PTRACE_DETACH后进程状态还是traced?
用ptrace attach一个进程后,向其写入一段代码,然后detach
为啥PTRACE_DETACH后进程状态还是traced?
TTY1
[root@localhost tmp]# gcc a.c -o target -ldl
[root@localhost tmp]# ./target
80483c8
hhhh
hhhh
hhhh
hhhh
[1]+ Stopped ./target
[root@localhost tmp]#
复制代码
TTY2
[root@localhost prog]# ps a
PID TTY STAT TIME COMMAND
2629 tty2 Ss+ 0:00 /sbin/mingetty tty2
2630 tty3 Ss+ 0:00 /sbin/mingetty tty3
2631 tty4 Ss+ 0:00 /sbin/mingetty tty4
2632 tty5 Ss+ 0:00 /sbin/mingetty tty5
2633 tty6 Ss+ 0:00 /sbin/mingetty tty6
2628 tty1 Ts+ 0:00 /sbin/mingetty tty1
1577 pts/2 Ss+ 0:00 -bash
11045 pts/1 Ss 0:00 -bash
11718 pts/3 Ss 0:00 -bash
12397 pts/4 Ss+ 0:00 -bash
13234 pts/1 S+ 0:00 ./target ## here
13236 pts/3 R+ 0:00 ps a
[root@localhost prog]# ./a.out 13234
b16050
80489ec
eip : a027a2
[root@localhost prog]# ps a
PID TTY STAT TIME COMMAND
2629 tty2 Ss+ 0:00 /sbin/mingetty tty2
2630 tty3 Ss+ 0:00 /sbin/mingetty tty3
2631 tty4 Ss+ 0:00 /sbin/mingetty tty4
2632 tty5 Ss+ 0:00 /sbin/mingetty tty5
2633 tty6 Ss+ 0:00 /sbin/mingetty tty6
2628 tty1 Ts+ 0:00 /sbin/mingetty tty1
1577 pts/2 Ss+ 0:00 -bash
11045 pts/1 Ss+ 0:00 -bash
11718 pts/3 Ss 0:00 -bash
12397 pts/4 Ss+ 0:00 -bash
13234 pts/1 T 0:00 ./target ## here
13238 pts/3 R+ 0:00 ps a
复制代码
注入的部分代码如下:
__asm__(
/// sys getpid
"movl $20, %eax\n\t"
"int $0x80\n\t"
/// kill()
"movl %eax, %ebx\n\t"
"movl $37, %eax\n\t"
"movl $19, %ecx\n\t"
"int $0x80\n\t"
复制代码
[
本帖最后由 rootclown 于 2007-1-5 13:57 编辑
]
作者:
Benson_linux
时间:
2007-04-10 10:03
把这个帖子顶起来,希望LZ看到,把内容在补全一些,你问题描述的不清楚啊。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2