跨内存连接.如何从子进程获取远程地址到父进程 [英] cross memory attach. How do I get the remote address from a child process to a parent process

查看:35
本文介绍了跨内存连接.如何从子进程获取远程地址到父进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Linux Kernel 3.2 版,并进一步具有称为跨内存连接的功能.

Linux Kernel version 3.2 and further have a capability called cross memory attach.

这是它的链接.在这方面,我无法得到很多帮助.http://man7.org/linux/man-pages/man2/process_vm_readv.2.html

Here is the link to it. I was not able to get a lot of help in that regard. http://man7.org/linux/man-pages/man2/process_vm_readv.2.html

在语法中,我们需要要写入或读取的远程内存的地址.我的问题是,如果我使用 fork(),如何获得这个远程内存的地址.

In the syntax we need the address of the remote memory where we want to write to or read from. My question is how do I get the address of this remote memory if I am using fork().

假设我使用跨内存连接从父进程向子进程发送一些东西.如何将远程内存的地址从子进程发送到父进程?

Suppose I am sending something from parent process to child process using cross memory attach. How do I send the address of the remote memory to the parent process from the child process?

推荐答案

系统调用 process_vm_readvprocess_vm_writev 用于进程之间的快速数据传输.除了一些传统的进程间通信方式之外,还应该使用它们.

The system calls process_vm_readv and process_vm_writev are meant for fast data transfer between processes. They are supposed to be used in addition to some traditional way of interprocess communication.

例如,您可以使用常规管道或 fifo 在您的进程之间传输所需的地址.然后您可以使用这些地址来建立更快的process_vm_ 通信.在分叉进程之间传输内容的最简单方法应该是 pipe() 函数(man 2 pipe 有一个很好的例子说明了它的用法).当然,还有许多其他方法可以做到这一点,例如使用套接字或消息.您甚至可以将地址写入文件并让其他进程读取它.

For example, you may use a regular pipe or fifo to transfer the required addresses between your processes. Then you may use those addresses to establish faster process_vm_ communication. The simpliest way to transfer something between forked processes should be the pipe() function (man 2 pipe has a good example of its usage). There are many other ways to do so of course, like using sockets or messages. You can even write an address to a file and let the other process read it.

这篇关于跨内存连接.如何从子进程获取远程地址到父进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆