Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int status;
- signal(SIGINT, SIG_DFL);
- if (fork() == 0)
- {
- int status;
- int pipet[2];
- pid_t pid1;
- pid_t pid2;
- if (pipe(pipet) == -1)
- _exit(EXIT_FAILURE);
- pid1 = fork();
- if (pid1 == 0)
- {
- close(pipet[0]);
- dup2(pipet[1], 1);
- execvp(code);
- }
- if (pid1 > 0)
- {
- close(pipet[1]);
- dup2(pipet[0], 0);
- execvp(code);
- }
- else
- {
- perror("Error");
- }
- close(pipet[0]);
- close(pipet[1]);
- wait(&status);
- }
- signal(SIGINT, SIG_IGN);
- wait(&status);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement