摘要: 通过信号完成父子进程间的通信 // 通过信号父子进程发送数据 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> void sig_parent(int 阅读全文
posted @ 2020-08-24 22:10 x_Aaron 阅读(444) 评论(0) 推荐(0)
摘要: 信号捕捉 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> void capture_sig(int code) { printf("capture s 阅读全文
posted @ 2020-08-24 21:13 x_Aaron 阅读(158) 评论(0) 推荐(0)
摘要: 信号忽略行为 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> int main() { struct sigaction nact, oact; na 阅读全文
posted @ 2020-08-24 21:09 x_Aaron 阅读(193) 评论(0) 推荐(0)
摘要: 设置屏蔽信号集 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> int main() { // 定义 sigset_t nset, oset; // 阅读全文
posted @ 2020-08-24 20:52 x_Aaron 阅读(101) 评论(0) 推荐(0)
摘要: Linux进程间的通信 常见的进程间通信方式: 管道(有名/匿名管道)、消息队列(systemv、posix两个版本)、内存共享映射(MMAP)、网络套接字 信号量、条件变量、互斥锁、文件锁、进程锁、信号等 管道 绝大多数进程间的通信都是基于内核区域 在内核中建立一个缓冲区, 两个进程向缓冲区读/写 阅读全文
posted @ 2020-08-24 20:40 x_Aaron 阅读(358) 评论(0) 推荐(0)
摘要: mmap进程间通信 写端 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcn 阅读全文
posted @ 2020-08-24 11:53 x_Aaron 阅读(165) 评论(0) 推荐(0)
摘要: 有名管道 进程A #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h 阅读全文
posted @ 2020-08-24 09:20 x_Aaron 阅读(125) 评论(0) 推荐(0)
摘要: 使用管道完成简单进程通信 /* 使用匿名管道完成父子进程通信 */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #define MESSAGE "can you hear me?" in 阅读全文
posted @ 2020-08-24 08:53 x_Aaron 阅读(179) 评论(0) 推荐(0)