使用 C++ 创建环境变量计算机图形图像处理
我想知道是否可以使用 C++ CGI 变量创建 C++ 环境变量。我正在考虑使用临时环境变量,以便我可以在两个 CGI 程序之间共享数据。
I was wondering if it would be possible to create a C++ environment variable using C++ CGI variable. I was thinking something along the lines of a temp environment variable so that I could share data between two CGI programs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从概念上讲,从进程(内部)设置的环境变量(CGI 程序就是这样)仅存在于该进程的生命周期或范围内。它们仅对该进程或其子进程“可见”(或可访问)。
此外,环境变量不是特定于“C++”的,而是操作系统(或 shell,取决于您来自哪里)的功能。
即使有可能,以这种方式交换数据也可能不是一个好主意。您无法(可靠/轻松地)使用环境变量解决并发修改等问题。
您应该研究 IPC(进程间通信)的其他概念。
Conceptually, environment variables being set from (inside) a process, which a CGI program is, only exist for the lifetime or in the scope of that process. They are only "visible" (or accessible) for that process or (possibly) its children.
Also, environment variables are not 'C++' specific, but an operating system (or shell, depending on where you come from) feature.
Even if it would be possible, it is arguably not a good idea to exchange data in that way. You could not (reliably/easily) address issues like concurrent modification, etc. with environment variables.
You should look into other concepts of IPC (interprocess communication).