remoteprocess
remoteprocess copied to clipboard
Use `PTRACE_SEIZE`/`PTRACE_INTERRUPT` instead of `PTRACE_ATTACH`
Use ptrace::seize/ptrace::interrupt to avoid needing to involve signals (e.g SIGSTOP, SIGTRAP+execve) when pausing pause threads, as these can cause race conditions with e.g. foreign processes that also send signals the tracee.
Some hints at GDB dealing with racy interactions between a ptraced process and signals handling w/ a foreign process: https://lkml.iu.edu/hypermail/linux/kernel/1102.2/00495.html. This was initially useful for me while debugging the original issue.
Also some context on the extra SIGTRAP+execve: https://man7.org/linux/man-pages/man2/ptrace.2.html#:~:text=execve(2)%20does%20not%20deliver%20an%20extra%20SIGTRAP.