本实例主要是关于在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){