#include #include #include #include #include using namespace std; int main(){ while(1){ // loop until return cout << "Command (one word only)> " << flush; string command; cin >> command; if(command == "exit"){ return 0; } else { pid_t returnedValue = fork(); if(returnedValue < 0){ perror("error forking"); return -1; } else if (returnedValue == 0){ execlp(command.c_str(), command.c_str(), NULL); perror(command.c_str()); return -1; } else { if(waitpid(returnedValue, 0, 0) < 0){ perror("error waiting for child"); return -1; } } } } }