summaryrefslogtreecommitdiff
path: root/user/sh.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2019-09-10 12:30:10 -0400
committerFrans Kaashoek <[email protected]>2019-09-10 12:30:10 -0400
commit7e6c37e67e6da62e02089fc3292569103b7e94b3 (patch)
tree8b3f2e762f1f0a32a4641d240d30b155af6ab34a /user/sh.c
parent035cca95fe87c67ee1e33b9edfb2d87e24476fa8 (diff)
downloadxv6-labs-7e6c37e67e6da62e02089fc3292569103b7e94b3.tar.gz
xv6-labs-7e6c37e67e6da62e02089fc3292569103b7e94b3.tar.bz2
xv6-labs-7e6c37e67e6da62e02089fc3292569103b7e94b3.zip
Support exit status for exit/wait
One test case for returning a exit status Passes usertests, but haven't used it to simplify tests
Diffstat (limited to 'user/sh.c')
-rw-r--r--user/sh.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/user/sh.c b/user/sh.c
index c573c99..74a493d 100644
--- a/user/sh.c
+++ b/user/sh.c
@@ -65,7 +65,7 @@ runcmd(struct cmd *cmd)
struct redircmd *rcmd;
if(cmd == 0)
- exit();
+ exit(-1);
switch(cmd->type){
default:
@@ -74,7 +74,7 @@ runcmd(struct cmd *cmd)
case EXEC:
ecmd = (struct execcmd*)cmd;
if(ecmd->argv[0] == 0)
- exit();
+ exit(-1);
exec(ecmd->argv[0], ecmd->argv);
fprintf(2, "exec %s failed\n", ecmd->argv[0]);
break;
@@ -84,7 +84,7 @@ runcmd(struct cmd *cmd)
close(rcmd->fd);
if(open(rcmd->file, rcmd->mode) < 0){
fprintf(2, "open %s failed\n", rcmd->file);
- exit();
+ exit(-1);
}
runcmd(rcmd->cmd);
break;
@@ -93,7 +93,7 @@ runcmd(struct cmd *cmd)
lcmd = (struct listcmd*)cmd;
if(fork1() == 0)
runcmd(lcmd->left);
- wait();
+ wait(0);
runcmd(lcmd->right);
break;
@@ -117,8 +117,8 @@ runcmd(struct cmd *cmd)
}
close(p[0]);
close(p[1]);
- wait();
- wait();
+ wait(0);
+ wait(0);
break;
case BACK:
@@ -127,7 +127,7 @@ runcmd(struct cmd *cmd)
runcmd(bcmd->cmd);
break;
}
- exit();
+ exit(0);
}
int
@@ -166,16 +166,16 @@ main(void)
}
if(fork1() == 0)
runcmd(parsecmd(buf));
- wait();
+ wait(0);
}
- exit();
+ exit(0);
}
void
panic(char *s)
{
fprintf(2, "%s\n", s);
- exit();
+ exit(-1);
}
int