diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-12-02 01:02:49 +0100 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-12-02 01:02:49 +0100 |
| commit | c2c03f41e078481921bad82487eded0fc51ebb59 (patch) | |
| tree | 1e310556c9a809aea112728bae9e0a6807ee0ba2 /userspace/foolshell.c | |
| parent | f20db37ca17245d5d20302a1ac1da347de5c3607 (diff) | |
further work on fork and friends
Diffstat (limited to 'userspace/foolshell.c')
| -rw-r--r-- | userspace/foolshell.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 78ba327..7d2291e 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -109,7 +109,7 @@ int process(char *buf) if(!strcmp(command,"help")) { - puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv/setenv [var] [val]', 'env' 'cd [dir]'"); + puts("foolshell: supported built-in commands: 'help', 'echo [string]', 'malloc [bytes]', 'free [address]', 'getenv [var]', 'putenv/setenv [var] [val]', 'env' 'cd [dir]', 'exit'"); } else if(!strcmp(command,"cd")) { @@ -173,6 +173,11 @@ int process(char *buf) setenv("PWD",buf,1); } + else if(!strcmp(command,"exit")) + { + exit(1); + + } else if(!strcmp(command,"echo")) { printf("\"%s\"\n",token[1]); @@ -215,12 +220,18 @@ int process(char *buf) if(pid!=0) { printf("new task pid: %i \n",pid); + } + if(pid==0) + { char buf[256]; sprintf(buf,"%s/%s",getenv("PATH"),token[0]); + sprintf(buf,"%s/%s","/bin",token[0]); execve(buf,token,environ); puts("foolshell: command not found"); exit(1); } + int status; + wait(&status); } return 0; |
