Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void execute(char **command)
- {
- /*
- * Handling of fork events. Prints [/bin/command] for clarity
- * Uses wait for proper process handling
- *
- */
- char path[512] = "/bin/";
- strcat(path, command[0]);
- pid_t pid;
- int status;
- pid = fork();
- if (pid < 0){
- printf("[-] ERROR while Forking\n");
- }
- else if (pid == 0) {
- printf("[%s]\n", path);
- if (execvp(*command, command) < 0){
- printf("No command %s found.\n", command[0]);
- }
- }
- else{
- while (wait(&status) != pid);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement