In your else that starts on line 30, you wait for your child process to exit, then exec another command. It will have nothing to talk to as the child process is already dead.
Also, check your return codes for ALL system calls, such as wait(), execlp(), etc.
What "while True" are you talking about? And you didn't need to delete the exit call to fix your program -- Your child process has exited by the time your call to wait() returns!
from dtscode:
1) Next time, please post a proper test case: http://eel.is/iso-c++/testcase/
2) execlp does in fact return something, but only under certain circumstances. It is probably best if you learn when it does
3) If you read the documentation, you would understand why your shell is exiting. Read this: http://linux.die.net/man/3/execlp and see if you can figure it out