Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- #include <stdlib.h>
- #include <error.h>
- #include <sys/types.h>
- int main(int argc, char **argv){
- int p[2], p1[2], pid, n, m;
- char buf[10], buf1[10];
- pipe(p);
- pipe(p1);
- pid = fork();
- if(pid){
- close(p[0]);
- close(p1[1]);
- write(p[1],"ciao",5);
- do{
- m = read(p1[0],buf1,10);
- }while(m < 1);
- exit(1);
- }
- else{
- close(p[1]);
- close(p1[0]);
- wait(NULL);
- n = read(p[0],buf,10);
- write(STDOUT_FILENO,buf,n);
- write(p1[1],"ok",3);
- exit(1);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement