Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <pre>
- #include <stdio.h>
- #include <errno.h>
- #include <unistd.h>
- int
- application(int argc, char* argv[])
- {
- char app1[] = "";
- char app2[] = "";
- switch (fork())
- {
- case -1 :
- perror("fork : ");
- return 0;
- case 0 :
- if (execvp((argc >= 2) ? app1 : app2, &argv[1]) == -1)
- {
- perror("execvp : ");
- return 0;
- }
- break;
- default :
- wait(NULL);
- }
- return 1;
- }
- int
- main(int argc, char* argv[])
- {
- if (argc != 2)
- {
- fprintf(stderr, "Usage...\n");
- return 1;
- }
- if (! application(argc, argv))
- {
- return 1;
- }
- return 0;
- }
- </pre>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement