0

I am trying to instrument processes with ptrace to access open file descriptors a process has, especially stdout and stderr. My main issue is that if process is multithreaded and has used unshare with CLONE_FILES then different threads might have different file descriptors. How do I access them in different threads in this case? E.g., how can I use dup2 inside tracee to set stdout to a different file descriptor? If it is single threaded then I can just call dup2 syscall, but what if it is multithreaded with file descriptors which are not shared?

Mitar
  • 6,756
  • 5
  • 54
  • 86

0 Answers0