两个进程可以通过 ptrace 附加到同一个 PID

Can two process attach to same PID via ptrace

所以,标题说明了一切。

有没有可能一个进程有两个tracer?

我正在玩 ptrace,我可以看到每当有人附加到进程时,TracerPID 下的 /proc//status 将是跟踪器的 PID。但是,有可能有两个示踪剂吗?

我有两个程序(tracer 和 tracee)。我在调试模式下 运行 tracee,然后我 运行 tracer,并得到错误 Operation not permitted (even with root permissions).

此致, 戈洛比奇

他们不能。在 ptrace 手册页中间接确认:

   EPERM  The  specified  process cannot be traced.  This could be because
          the tracer has insufficient privileges (the required  capability
          is  CAP_SYS_PTRACE);  unprivileged  processes  cannot trace pro‐
          cesses that they cannot send signals to or  those  running  set-
          user-ID/set-group-ID  programs,  for  obvious reasons.  Alterna‐
          tively, the process may already be being traced, or (on  kernels
          before 2.6.26) be init(1) (PID 1).