4

我有一个服务器应用程序,可以使用 inetd 为客户端调用。但是,如果我尝试附加到使用 inetd 启动的服务器进程,我会收到以下响应:ptrace: Operation not allowed。

gdb --annotate=3 /my/app/here <processId>

Current directory is /usr/local/bin/
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Reading symbols from /usr/local/bin/flumed...done.
Using host libthread_db library "/lib/tls/libthread_db.so.1".
Attaching to program: /my/app/here, process <processId>
ptrace: Operation not permitted.
/usr/local/bin/<processId>: No such file or directory.
(gdb) 
4

5 回答 5

8

我的解决方案是这样的:

echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
于 2011-06-07T15:53:13.997 回答
2

显然,在用户 ID 不是 root 的情况下,使用 inetd 会变得很奇怪。您最终会得到一个具有奇怪权限的进程。例如,即使权限为 777,您也无法读取 /proc/self/exe。我怀疑这个问题更相似。即使我是该进程的用户 ID,我也没有权限。为 gdb 使用 root 是一种解决方法。

于 2009-10-24T15:16:55.273 回答
2

进一步的 tgoodhart 说,其他ptrace用户喜欢/usr/bin/strace也将阻止gdb

于 2013-03-24T08:49:23.900 回答
0

我也看到当多个 gdb 实例同时运行时会出现此问题,通常是因为我未能正确关闭 gdb。关闭这些泄露的实例解决了这个问题。

于 2011-07-22T16:22:05.207 回答
-1

请运行以下命令来解决您的问题:

sudo chmod +s /usr/bin/gdb

于 2013-06-28T09:16:03.753 回答