问题描述
我需要在不使用 IPC :: Shareable .
我基本上只需要有一个全局变量,所有进程都可以读取/写入.另外,如果该变量使我的答案更简单,则仅需要父级的写访问权限.孩子们只需要阅读它即可.
I basically just need to have a global variable that all processes would be able to read/write to. Also, the variable only needs write access from the parent if that would make my answer simpler. The Children only need to read it.
如果我有办法将消息从一个子进程传递给另一个子进程,也可以解决我的问题
My problem could also be solved if there is a way for me to pass a message from one child process to another
推荐答案
从您提供的信息中很难分辨出哪种是最佳解决方案,但是有一些可用的选择:
From the information you have provided it's difficult to tell which is the best solution, but there are a few options available to you:
- 使用套接字或管道在进程之间传递消息
- 使用两个进程均可读写的数据库
- 使用两个进程都可以读写的文件(您可以使用信号告诉进程何时是从文件中读取的时间)
- 设置内存缓存服务器以共享信息
...但是,由于您的 real 问题实际上可能是我如何在Perl中执行需要在系统上未安装模块且我没有root用户的操作控制此框,系统管理员无法合作还是无法合作?".最好的答案是使用 local :: lib ",但是您可以阅读更多内容Matt Trout的博客文章中的选项但是我不能使用CPAN!" . (我发誓我每周都会发布此链接.)
...However, since your real problem might actually be "how can I do something in Perl that requires a module that isn't installed on my system, and I don't have root control over this box and sysadmins can't or won't cooperate?". the best answer is "use local::lib", but you can read more options in Matt Trout's blog post "But I can't use CPAN!". (I swear I post this link every single week.)
这篇关于在没有IPC :: Shareable的perl中的子进程之间共享变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!