diff --git a/msh.c b/msh.c index fe66427..b62880a 100644 --- a/msh.c +++ b/msh.c @@ -316,10 +316,15 @@ int mathTest() { #ifndef RELEASEBUILD printf("Answer: %ld\n", numSolution); #endif - printf("%d %c %d = ", num1, mathOperation[randProblem], num2); - numLine = readline(""); - if (numLine != NULL && strlen(numLine) > 0) { - sscanf(numLine, "%ld", &numAnswer); + while(numLine == NULL) { + printf("%d %c %d = ", num1, mathOperation[randProblem], num2); + numLine = readline(""); + + if (numLine != NULL && strlen(numLine) > 0) { + sscanf(numLine, "%ld", &numAnswer); + } + + free(numLine); } if (numSolution != numAnswer) { // If wrong answer @@ -337,7 +342,6 @@ int mathTest() { printf("\n"); #endif - free(numLine); return status; } @@ -370,6 +374,8 @@ void startShell() { } free(line); } + printf("Exiting Shell\n"); + sleep(2); free(prompt); prompt = NULL; }