My assignment is to write a simple linux shell. I'm on external commands. We need to use execv.
for (int i = 0; i < count; i++){
char path[1024];
strcpy(path, PATHS[i]); // PATHS is an array of cstrings, the paths in $PATH
strcat(path, "/");
strcat(path, command[0]); // command and commands are essentially the same
printf("%d %s",i,path); // they are essentially argv[]
if (!execv(path, commands)) // for ls -l $HOME
break; // commands[0] = ls [1] = -l [2] = my home dir
right now I'm only testing it with ls. ls runs exactly as it should, but the program closes immediately after execv succeeds. Is there any way for me to keep using execv to check for the correct path and for the program to continue running after execv succeeds?