getpeername always gives bad file descriptor

做~自己de王妃 提交于 2019-12-02 08:37:00

socket descriptor is not shared between two processes. the captured socket descriptor is only effective in the traced process, and not effective in the tracer process. that's why getpeername complains bad descriptor.
from the manual of ptrace:
The ptrace() system call provides a means by which a parent process may observe and control the execution of another process, and examine and change its core image and registers. It is primarily used to implement breakpoint debugging and system call tracing.
there's no word says they share process space, thus, they can not share socket descriptors, memory address, etc..

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!