最近在ubuntu上搭建了一个postgres的调试开发环境,详情请见http://wiki.postgresql.org/wiki/Working_with_Eclipse。
ubuntu的版本为12.04 结果在用eclipse调试postgres的子进程postgres的时候遇到了如下问题:
Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
经过查阅有关资料发现,从ubuntu10.10开始,除非进程B是进程A的子进程,或者进程A为root运行,否则进程A不能调试进程B。这样一来增加了进程的安全。这个安全限制是默认的,但是可以通过修改配置文件来达到任意进程A可以调试进程B的目的。
1.可以通过下面的命令对这个限制进行临时修改,但是重启后限制依旧存在。
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
2.可以通过修改配置文件来接触限制
修改前:
kernel.yama.ptrace_scope = 1
修改后:
kernel.yama.ptrace_scope = 0
重启之后可以生效