关于setEnv()的方法和使用范围
我想将setEnv()用于数据传输,如下所示:
首先,我将int转换为字符串,然后在过程中设置一个变量,例如:
setEnv(测试,测试,1)
其中测试是环境变量的名称,测试是转换后的数字字符串,而1表示可以覆盖它。
然后,在子进程叉中,我可以通过getEnv获得与此变量相对应的字符串测试,然后通过atoi()进入相应的数据,以完成我需要的数据传输。
现在,我想在过程之间实现数据传输,但是典型的三向管,命名为管道,共享内存方法太贵了,我只需要传递一个数字,而setEnv()和getenv()似乎通过仅在同一过程之间。
因此,我想知道除了三种典型的流程通信方法外,还有其他方法可以在过程之间实施内容传输。此转移只需要一次执行一次,并且是单向的。如果使用setenv(),如何设置它?
I want to use setenv() for data transfer as follows:
First, I convert an int to string, and then set a variable in a process, for example:
setenv(TEST, test, 1)
where TEST is the name of the environment variable, test is the converted numeric string, and 1 means that it can be overwritten.
Then, in the child process fork, I can get the string test corresponding to this variable through getenv, and then through atoi() into the corresponding data, so as to complete the data transfer I need.
Now, I want to implement data transfer between processes, but the typical three-way pipe, named pipe, and shared memory approach is too expensive and I just need to pass a single number, whereas setenv() and getenv() seem to pass only between the same process.
So, I wonder if there are any other ways to implement content transfer between processes besides the three typical process communication methods. This transfer only needs to be executed once and is one-way. How to set it up if setenv() is used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论