mzz2017 / gg

一个支持节点与订阅链接的 Linux 命令行代理工具 | A command-line tool for one-click proxy in your research and development without installing v2ray or anything else (only for linux)
GNU Affero General Public License v3.0
1.47k stars 117 forks source link

linux可以支持attach到一个已存在的进程吗 #35

Open contestjia opened 1 year ago

mzz2017 commented 1 year ago

我印象里 ptrace 只支持 attach 到自己的子进程

contestjia commented 1 year ago

ptrace可以的 https://man7.org/linux/man-pages/man2/ptrace.2.html A process can initiate a trace by calling [fork(2)](https://man7.org/linux/man-pages/man2/fork.2.html) and having the resulting child do a PTRACE_TRACEME, followed (typically) by an [execve(2)](https://man7.org/linux/man-pages/man2/execve.2.html). Alternatively, one process may commence tracing another process using PTRACE_ATTACH or PTRACE_SEIZE.

mzz2017 commented 1 year ago

不错,看起来可行。可以加到todolist。不过近期我可能没有时间,我正在推进其他项目🥲

contestjia commented 1 year ago

不错,看起来可行。可以加到todolist。不过近期我可能没有时间,我正在推进其他项目🥲

可以的,我也试着在fork仓库里加了下attach,但运行一会儿就会被hang住

mzz2017 commented 1 year ago

有些奇怪,可能需要进一步排查在哪里hang住了。可以从简单的程序开始调试。

期待你的任何进展~