[201514636@ln01 C]$ cat pipe_pro.c
#include<sys/types.h>
#include<unistd.h>
#include<stdio.h>
#include<limits.h>
#define BUFSIZE PIPE_BUF //PIPE_BUG:管道默认一次性读写的数据长度
void err_quit(char *msg)
{
printf(msg);
exit(0);
}
int main(int argc,char* argv[])
{
int fd[2];
char buf[BUFSIZE]="hello my brathor\n";/*写入管道的缓冲区*/
pid_t pid;
int len;
if((pipe(fd))<0)//创建管道
err_quit("pipe failed\n");
if((pid=fork())<0)
e
#include<sys/types.h>
#include<unistd.h>
#include<stdio.h>
#include<limits.h>
#define BUFSIZE PIPE_BUF //PIPE_BUG:管道默认一次性读写的数据长度
void err_quit(char *msg)
{
printf(msg);
exit(0);
}
int main(int argc,char* argv[])
{
int fd[2];
char buf[BUFSIZE]="hello my brathor\n";/*写入管道的缓冲区*/
pid_t pid;
int len;
if((pipe(fd))<0)//创建管道
err_quit("pipe failed\n");
if((pid=fork())<0)
e