int handleCommand(char *command) {
pid_t pid;
pid = fork();
if (pid > 0) {
sleep(0.5);
} else if (pid == 0) {
execCommand(command);
//strcat(path[0], command);
//printf("%s", path[0]);
//execve(path[0], path, NULL);
//printf("\n");
} else {
printf("ERROR");
}
}
int execCommand(char *command) {
char* path[] = {"/bin/", NULL};
printf("in execCommand > %s", command );
strcat(path[0], command);
execve(path[0], path, NULL);
printf("\n");
}
at first as you can see i put the code directly in the function where the fork takes place. This would display the output expected when executing the ls command for example. But when I moved this to a function i no longer see any output.