From 374022ee7abb50c41c0a88a40b5bebe5d8bb7cd6 Mon Sep 17 00:00:00 2001 From: shockrah Date: Tue, 17 Sep 2019 00:25:55 -0700 Subject: [PATCH] homework 3 i think --- 334/homework/3/msh.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/334/homework/3/msh.c b/334/homework/3/msh.c index 6ad650d..73e6511 100644 --- a/334/homework/3/msh.c +++ b/334/homework/3/msh.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -93,13 +94,15 @@ int builtin_response(char* buffer) { // Execute child process pid_t child = fork(); - if(child) { + if(child != 0) { int status_child = wait(NULL); if(status_child == 127) { - echo("command not found: oh btw remember to not print this string kek"); + printf("msh: %s: %d", tokens[0], status_child); } } - execvp(tokens[0], tokens); + else { + execvp(tokens[0], tokens); + } // Cleanup pointers for(int i = 0; i< 64; i++) { tokens[i] = NULL;