Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- int main(int argc, char **argv[]) {
- pid_t process_1;
- pid_t process_2;
- int fisier;
- int pipe_1[2];
- int pipe_2[2];
- if(-1 == pipe(pipe_1)) {
- perror("Eroare la pipe!");
- return -1;
- }
- process_1 = fork();
- if(-1 == process_1){
- perror("Eroare la fork!");
- return -2;
- }
- else
- if(process_1 != 0) {
- if(-1 == pipe(pipe_2)) {
- perror("Eroare la pipe!");
- return -3;
- }
- process_2 = fork();
- if(process_2 == -1) {
- perror("Eroare la fork!");
- }
- if(process_2 != 0) {
- wait(NULL);
- } else if(process_2 == 0) {
- execl("/bin/wc", "wc", "-l", "p3.c" , NULL);
- }
- }
- if(process_1 == 0) {
- execl("/bin/wc", "wc", "-w", "p3.c" , NULL);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement