Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pid_t pid;
- int status;
- if ((pid = fork())< 0){
- printf("*** ERROR: forking child process failed\n");
- exit(1);
- }
- else if (pid == 0) { /* for the child process: */
- if (execvp(*name, name) < 0) { /* execute the command */
- printf("*** ERROR: exec failed\n");
- exit(1);
- }
- }
- else { /* for the parent: */
- while (wait(&status) != pid) /* wait for completion */;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement