Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <sys/wait.h>
- int
- execute(char *arg)
- {
- int status = 0;
- pid_t pid = fork();
- if (pid == -1) {
- return 0;
- } else if (!pid) {
- execlp(arg, arg, NULL);
- _exit(1);
- }
- wait(&status);
- return (WIFEXITED(status) && !WEXITSTATUS(status));
- }
- int
- main(int argc, char *argv[])
- {
- return ((!execute(argv[1]) || !execute(argv[2])) && !execute(argv[3]));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement