Upload Code
loading-left
loading loading loading
loading-right

Loading

Profile
No self-introduction
codes (1)
Pipeline Communications
no vote
int main(int argc, char **argv) { int pipefds[2],pipefds2[2]; pid_t pid; int i,j; char buffer[255]; If (pipe (pipefds) < 0)//first pipeline { printf("errorn"); } pid=fork(); if(pid<0) exit(1); if (pid==0) { close(pipefds[1]); memset(buffer,0,sizeof(buffer)); while(1) { I=read (pipefds[0],buffer,sizeof (buffer));//if it is empty (preceded by a child process after the fork), then block does not move if(0==i) break; printf("%sn",buffer); } close(pipefds[0]); exit(0); } else { close(pipefds[0]); scanf("%s",buffer); write(pipefds[1],buffer,strlen(buffer)); close(pipefds[1]); wait(NULL); exit(0); } }
haohaoxuexi4
2016-08-23
0
1
No more~