Linux 进程间通信(IPC)示例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6003545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Examples of inter process communication(IPC)
提问by xyz
I am wondering about actual examples or instances of inter process communication (IPC) which we encounter on a daily basis (which happen under the hood or otherwise) while using our laptop/desktop. I have always read about these theoretically from a textbook.
我想知道我们在使用笔记本电脑/台式机时每天遇到的进程间通信 (IPC) 的实际示例或实例(发生在幕后或其他情况下)。我总是从教科书中从理论上读到这些。
For example:
例如:
Between a parent process and child processes: one example of this in Linux I know is when a shell starts other processes and we can kill those processes using their process IDs.
Between two unrelated (in hierarchy) but cooperating processes?
在父进程和子进程之间:我知道在 Linux 中的一个例子是当 shell 启动其他进程时,我们可以使用它们的进程 ID 杀死这些进程。
在两个不相关(在层次结构中)但合作的进程之间?
回答by karlphillip
One way of doing IPC on the two cases you mentioned is using sockets.
在您提到的两种情况下进行 IPC 的一种方法是使用sockets。
I recommend taking a look at Beej's Guide to Unix Interprocess Communicationfor information and examples.
我建议查看Beej 的 Unix 进程间通信指南以获取信息和示例。
回答by Kim Stebel
Some examples of IPC we encounter on a daily basis:
我们每天都会遇到的一些 IPC 示例:
- X applications communicate with the X server through network protocols.
- Pipes are a form of IPC:
grep foo file | sort
- Servers like Apache spawn child processes to handle requests.
- many more I can't think of right now
- X 应用程序通过网络协议与 X 服务器通信。
- 管道是 IPC 的一种形式:
grep foo file | sort
- 像 Apache 这样的服务器会产生子进程来处理请求。
- 还有很多我现在想不起来
And I am not even mentioning examples of IPC where the processes are on different computers.
我什至没有提到进程在不同计算机上的 IPC 示例。