While experimenting with a system call ptrace(), I am trying to track another thread of the same process. According to the man page, both the tracer and the trace are specific threads (not processes), so I see no reason why this should not work. So far I have tried the following:
- use
PTRACE_TRACEMEfrom child clone()d: the call succeeds but does not do what I want, perhaps because the parent thread to be monitored is not a thread calledclone() - use
PTRACE_ATTACHor PTRACE_SEIZEfrom the parent thread: this always fails with EPERM, even if the process runs as root and withprctl(PR_SET_DUMPABLE, 1)
In all cases waitpid(-1, &status, __WALL)fails with ECHILD(same thing when passing child pid explicitly).
What to do to make it work?
If this is not possible at all, it is due to a bug or a bug in the kernel (I am using version 3.8.0). In the first case, could you tell me the correct bit of documentation?
source
share