#include #include #include #include #include #include "Integrated.h" #include "Pish.h" // Prints a prompt and then reads a command from the terminal char* getInput(void) { char prompt = '$'; char *commandLine; printf("%c ", prompt); scanf("%[^\n]", commandLine); return commandLine; } // Executes a command to the system void exec(char* command) { system(command); } // Main function for Pish program void Pish(void) { char* command; int retval; while (1) { command = getInput(); //Parse command char* token = strtok(command, " "); while(token != NULL) { //This only holds 1 command at a time then it overrides //Will need modified token = strtok(NULL, " "); } IntegratedCheck(command); retval = fork(); // Child if (retval == 0) { // This is the child process // Setup the child's process environment here // E.g., where is standard I/O, how to handle signals? exec(command); // exec does not return if it succeeds printf("ERROR: Could not execute %s\n", command); exit(1); } // Parent else { // This is the parent process; Wait for the child to finish int pid = retval; wait(pid); } // TODO: Remove break when while loop doesn't break program break; } }