error exit status is 1
This commit is contained in:
parent
7e6c37e67e
commit
35010f0d0f
|
@ -12,12 +12,12 @@ cat(int fd)
|
|||
while((n = read(fd, buf, sizeof(buf))) > 0) {
|
||||
if (write(1, buf, n) != n) {
|
||||
printf("cat: write error\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if(n < 0){
|
||||
printf("cat: read error\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,13 +28,13 @@ main(int argc, char *argv[])
|
|||
|
||||
if(argc <= 1){
|
||||
cat(0);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for(i = 1; i < argc; i++){
|
||||
if((fd = open(argv[i], 0)) < 0){
|
||||
printf("cat: cannot open %s\n", argv[i]);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
cat(fd);
|
||||
close(fd);
|
||||
|
|
|
@ -30,19 +30,19 @@ forktest(void)
|
|||
|
||||
if(n == N){
|
||||
print("fork claimed to work N times!\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for(; n > 0; n--){
|
||||
if(wait(0) < 0){
|
||||
print("wait stopped early\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if(wait(0) != -1){
|
||||
print("wait got too many\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
print("fork test OK\n");
|
||||
|
|
|
@ -41,7 +41,7 @@ main(int argc, char *argv[])
|
|||
|
||||
if(argc <= 1){
|
||||
fprintf(2, "usage: grep pattern [file ...]\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
pattern = argv[1];
|
||||
|
||||
|
@ -53,7 +53,7 @@ main(int argc, char *argv[])
|
|||
for(i = 2; i < argc; i++){
|
||||
if((fd = open(argv[i], 0)) < 0){
|
||||
printf("grep: cannot open %s\n", argv[i]);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
grep(pattern, fd);
|
||||
close(fd);
|
||||
|
|
|
@ -24,12 +24,12 @@ main(void)
|
|||
pid = fork();
|
||||
if(pid < 0){
|
||||
printf("init: fork failed\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if(pid == 0){
|
||||
exec("sh", argv);
|
||||
printf("init: exec sh failed\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
while((wpid=wait(0)) >= 0 && wpid != pid){
|
||||
//printf("zombie!\n");
|
||||
|
|
|
@ -9,7 +9,7 @@ main(int argc, char **argv)
|
|||
|
||||
if(argc < 2){
|
||||
fprintf(2, "usage: kill pid...\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
for(i=1; i<argc; i++)
|
||||
kill(atoi(argv[i]));
|
||||
|
|
|
@ -7,7 +7,7 @@ main(int argc, char *argv[])
|
|||
{
|
||||
if(argc != 3){
|
||||
fprintf(2, "Usage: ln old new\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
if(link(argv[1], argv[2]) < 0)
|
||||
fprintf(2, "link %s %s: failed\n", argv[1], argv[2]);
|
||||
|
|
|
@ -9,7 +9,7 @@ main(int argc, char *argv[])
|
|||
|
||||
if(argc < 2){
|
||||
fprintf(2, "Usage: mkdir files...\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for(i = 1; i < argc; i++){
|
||||
|
|
|
@ -9,7 +9,7 @@ main(int argc, char *argv[])
|
|||
|
||||
if(argc < 2){
|
||||
fprintf(2, "Usage: rm files...\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for(i = 1; i < argc; i++){
|
||||
|
|
|
@ -65,7 +65,7 @@ runcmd(struct cmd *cmd)
|
|||
struct redircmd *rcmd;
|
||||
|
||||
if(cmd == 0)
|
||||
exit(-1);
|
||||
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(-1);
|
||||
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(-1);
|
||||
exit(1);
|
||||
}
|
||||
runcmd(rcmd->cmd);
|
||||
break;
|
||||
|
@ -175,7 +175,7 @@ void
|
|||
panic(char *s)
|
||||
{
|
||||
fprintf(2, "%s\n", s);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
378
user/usertests.c
378
user/usertests.c
File diff suppressed because it is too large
Load diff
|
@ -27,7 +27,7 @@ wc(int fd, char *name)
|
|||
}
|
||||
if(n < 0){
|
||||
printf("wc: read error\n");
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
printf("%d %d %d %s\n", l, w, c, name);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ main(int argc, char *argv[])
|
|||
for(i = 1; i < argc; i++){
|
||||
if((fd = open(argv[i], 0)) < 0){
|
||||
printf("wc: cannot open %s\n", argv[i]);
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
wc(fd, argv[i]);
|
||||
close(fd);
|
||||
|
|
Loading…
Reference in a new issue