diff --git a/Makefile b/Makefile index 019fca5..c749080 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ main: gcc $(INC) -c -o build/Pish.o src/Pish.c exec: - gcc -o bin/pish build/*.o + gcc -o bin/pish.out build/*.o clean: rm build/* diff --git a/bin/pish b/bin/pish deleted file mode 100755 index c701370..0000000 Binary files a/bin/pish and /dev/null differ diff --git a/include/.keep b/include/.keep new file mode 100644 index 0000000..e69de29 diff --git a/include/Pish.h b/include/Pish.h new file mode 100644 index 0000000..fd60acd --- /dev/null +++ b/include/Pish.h @@ -0,0 +1,8 @@ +#ifndef PISH_H +#define PISH_H + +char* getcmd(void); +void exec(char* command); +void Pish(void); + +#endif diff --git a/src/Pish.c b/src/Pish.c new file mode 100644 index 0000000..576a2e7 --- /dev/null +++ b/src/Pish.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include "Pish.h" + +// Dummy function for Pish to run +char* getcmd(void) +{ + ; +} + +// Dummy function for Pish to run +void exec(char* command) +{ + ; +} + + + +void Pish(void) +{ + while (1) + { + char *cmd = getcmd(); + int retval = fork(); + 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(cmd); + // exec does not return if it succeeds + printf("ERROR: Could not execute %s\n", cmd); + exit(1); + } else { + // This is the parent process; Wait for the child to finish + int pid = retval; + wait(pid); + } + } +} diff --git a/src/main.c b/src/main.c index 49d012e..3b80286 100644 --- a/src/main.c +++ b/src/main.c @@ -1,6 +1,6 @@ -#include +#include "Pish.h" int main() { - printf("Hello world\n"); + Pish(); }