fork创建子进程,pipe及read、write实现进程间通信
#include <stdio.h>
#include <unistd.h>
main()
{
int i;
int ppid[2];
pipe(ppid);
int pid = fork();
if (0 == pid)
{
write(ppid[1],"test",sizeof("test"));
}
else
{
char buf[128] = {0};
read(ppid[0],buf,128);
printf("buf is %s\n",buf);
}
}