Linux进程间通信
Linux进程间通信分享
linuxcpp_
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Linux进程间通信
Linux进程间通信IPC方法管道管道的概念 IPC方法 Linux 环境下,进程地址空间相互独立,每个进程各自有不同的用户地址空间。任何一个进程的全局变量在另一个进程中都看不到,所以进程和进程之间不能相互访问,要交换数据必须通过内核,在内核中开辟一块缓冲区,进程 1 把数据从用户空间拷到内核缓冲区,进程 2 再从内核缓冲区把数据读走,内核提供的这种机制称为进程间通信(IPC, InterProcess Communication)。 在进程间完成数据传递需要借助操作系统提供特殊的方法,如:文件、管道、信原创 2020-12-08 14:39:24 · 270 阅读 · 0 评论 -
共享内存用于进程间通信
共享内存用于进程间通信共享内存在父子进程间通信示例共享内存在无血缘关系进程间通信写端示例读端示例 共享内存在父子进程间通信 示例 /* * function: 演示使用mmap()函数实现使用共享映射区完成父子进程间通信 * * 2020-12-07 */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.原创 2020-12-08 14:12:01 · 188 阅读 · 1 评论 -
UNIX域套接字
UNIX域套接字[udp]服务端客户端 服务端 /* * function: 演示本地unix域套接字用于进程间通信 * 此进程为服务端 * * 2020-12-05 */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/socket.h> #include <sys/un.h> // struct sockad原创 2020-12-07 20:16:28 · 233 阅读 · 0 评论 -
mkfifo_w/mkfifo_r.cpp
mkfifo_w.cpp /* * function: 演示使用mkfifo创建管道,并实现无血缘关系的进程间通信 * 此进程为写端 * * 2020-12-05 */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> int main(int argc, char原创 2020-12-05 20:16:15 · 133 阅读 · 0 评论 -
pipe 实现命令 ls | wc -l
/* * function: 使用管道实现父子进程间通信,完成: ls | wc –l。 * * 2020-12-01 */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main(int argc, char *argv[]) { int fd[2] = {0}; int ret = pipe(fd); // 创建管道 if (ret < 0)原创 2020-12-01 22:15:02 · 651 阅读 · 0 评论 -
pipe.cpp
/* * function: 演示使用pipe函数创建管道,并完成进程间通信 * * int pipe(int fildes[2]); // 成功:0,失败:-1,设置errno * * 2020-12-01 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int main(int argc, char *argv[]) {原创 2020-12-01 21:35:38 · 199 阅读 · 0 评论
分享