#include main(char * argv[],int argc) { char *name="./pipeclient"; char a[10]; int pid,fd[2]; int i; if (pipe(fd) == -1) { fprintf(stderr," pipe failed \n"); exit(-1); } switch (pid = fork()) { case -1 : fprintf(stderr," fork failed \n"); exit(-2); case 0 : if (close(fd[1]) == -1) /* child process */ { fprintf(stderr," close\n"); exit(-3); } sprintf(a,"%d",fd[0]); execlp(name,"pread",a,NULL); fprintf(stderr," execlp error \n"); } if (close(fd[0]) == -1) { fprintf(stderr," close2 \n"); exit(-4); } if (write(fd[1],"hello",5) == -1) { fprintf(stderr," write error \n"); exit(-5); } i = 6; if (write(fd[1],&i,4) == -1) { fprintf(stderr," write int error \n"); exit(-6); } while (wait((int *)0) != pid) /* wait child to terminate */ ; }