I'm trying to write a code about a process that executes programs from $PATH using the execlp() command.(it doesn't need to be the execlp command but I've found it useful for this one) I've achieved my expected output, but I need to run more than one commands. More specifically I want the child process to run the exec command, then the parent process to print a text indicating that it's ready to accept another command. Then the child process will run the new exec command. My code is this:
int main ( int argc, char *argp[]) { 
pid_t progpid = fork(); // the fork command for the creation of the child process
int status = 0;
char com[256];
if (progpid < 0)  // the check in case of failure
   {
    printf("PROGRAM ABORTED!");
    return 0;
   }
do
   {
    if (progpid == 0)  // the child process
      {
       scanf( "%s", com);
         if (com == "exit")
          {
            exit(0);
          }
        else
            {
               execlp(com, com, NULL);
            }
      }
else //the parent process
    {
      wait(&status);
      printf("$");
    }
}while (com != "exit");
return 0;
}
The expected output is :
<program which I input from keyboard> ( for example  : ls )
<output of the program>
$<next program>
<output of the next program>
.
.
.
$exit
In short I want to keep running programs till I enter exit where it ends without doing anything else. However the output I get is this:
<program>
<output of program>
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
It keeps printing $ until I shut it down. I'm new to processes so please don't be too harsh about my code so far. Thank you in advance!
 
     
    