c 的多进程编程实例

这篇博客详细介绍了如何在Linux上使用C语言进行多进程编程,包括通过fork函数创建子进程,以及利用pipe实现父子进程间的通信。实例中展示了如何在子进程向父进程发送信号,是理解C语言多进程和管道通信的好资料。
摘要由CSDN通过智能技术生成

本实例主要是关于在linux上的c语言编程,涉及到pipe在master process 和 sub process之间的交互。 如何利用fork创建multi-process, 如何利用从子进程中发送信号到父进程。



#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <string.h>
#include <signal.h>
#include <poll.h>
int notify(int pipe,int pipe_in_master,int i){
printf("from child %d to notify pipe %d, where master pipe0 is pipe:%d\n",i,pipe,pipe_in_master);
//close the wirte pipe to call poll and notify master.
close(pipe);

//print the content to standard output console
fflush(stdout);
}
int main(int argc,char ** argv){


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值