Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<unistd.h>
- #include<fcntl.h>
- #include<stdio.h>
- #include<stdlib.h>
- #include<errno.h>
- int main()
- { int pid,p[2];
- if(-1==pipe(p))
- {printf("Eroare pipe");
- exit(1);
- }
- if(-1==(pid=fork()))
- {printf("Eroare la fork");
- exit(2);
- }
- if(pid==0)
- {dup2(p[1],1);
- execlp("grep","grep","/bin/bash","/etc/passwd",NULL);
- perror("Eroare la execlp");
- exit(3);
- }
- if(pid!=0)
- {
- close(p[1]);
- dup2(p[0],0);
- execlp("cut","cut","-d,","-f1",NULL);
- perror("Eroare la execlp");
- exit(5);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment