简体   繁体   English

Linux,执行如何运行子二进制文件并有效地传递有效载荷?

[英]Linux, execve how to run a child binary and pass payload efficently?

till today when i was starting up a child program in my application (distributed computing) i used execv and as an argument i was passing a filename which has a payload stored. 直到今天,当我在我的应用程序(分布式计算)中启动子程序时,我都使用execv并作为参数传递了存储有效负载的文件名。

So i had two files: 所以我有两个文件:

1) child-program.binary (+x) 1)子程序二进制文件(+ x)

2) child-program.payload (+r) 2)child-program.payload(+ r)

When child-program.binary executed it knew that it has to load child-program.payload on startup, then the computing took place and the new payload was stored into child-program.payload file. 当child-program.binary执行时,它知道必须在启动时加载child-program.payload,然后进行计算并将新的有效负载存储到child-program.payload文件中。

i would like to change that and instead of storing payload on the hard drive, i would love to run the binary and pass the payload the different way, maybe via pipes? 我想更改它,而不是将有效负载存储在硬盘驱动器上,我想运行二进制文件并以不同的方式(可能通过管道)传递有效负载?

Also, do i have to store the binary on the hard disk to be able to run it? 另外,我是否必须将二进制文件存储在硬盘上才能运行它? Isn't there any other memory like option to execute something? 是否没有其他类似选项的内存来执行某些操作?

What are the possible options? 有哪些可能的选择?

Thanks all ! 谢谢大家!

The advantage of your file-approach is that it is non-volatile and the data can be easily distributed around the globe as file. 文件处理的优点是它是非易失性的,数据可以很容易地作为文件分布在全球范围内。

Based on your thought about pipes, I assume your "distributed computing" is on the same node. 根据您对管道的想法,我假设您的“分布式计算”在同一节点上。 You could also use shared memory see: shm_open and pass the name of the "file" name of your shared memory to the child. 您还可以使用共享内存,请参见: shm_open并将共享内存的“文件”名称传递给子级。 BTW. 顺便说一句。 Pipes or FIFOs let you easily synchornize using poll/select. 管道或FIFO使您可以使用轮询/选择轻松进行同步。 AFAIK you need a bit more infrastructure to synchronize access to Shared Memory. AFAIK您需要更多的基础结构来同步对共享内存的访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM