Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. void execute(char **command)
  2. {
  3. /*
  4. * Handling of fork events. Prints [/bin/command] for clarity
  5. * Uses wait for proper process handling
  6. *
  7. */
  8.  
  9. char path[512] = "/bin/";
  10. strcat(path, command[0]);
  11. pid_t pid;
  12. int status;
  13. pid = fork();
  14. if (pid < 0){
  15. printf("[-] ERROR while Forking\n");
  16. }
  17. else if (pid == 0) {
  18. printf("[%s]\n", path);
  19. if (execvp(*command, command) < 0){
  20. printf("No command %s found.\n", command[0]);
  21. }
  22.  
  23. }
  24. else{
  25. while (wait(&status) != pid);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement