diff options
author | Frans Kaashoek <[email protected]> | 2019-09-10 12:30:10 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2019-09-10 12:30:10 -0400 |
commit | 7e6c37e67e6da62e02089fc3292569103b7e94b3 (patch) | |
tree | 8b3f2e762f1f0a32a4641d240d30b155af6ab34a /user/cat.c | |
parent | 035cca95fe87c67ee1e33b9edfb2d87e24476fa8 (diff) | |
download | xv6-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/cat.c')
-rw-r--r-- | user/cat.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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(); + exit(-1); } } if(n < 0){ printf("cat: read error\n"); - exit(); + exit(-1); } } @@ -28,16 +28,16 @@ main(int argc, char *argv[]) if(argc <= 1){ cat(0); - exit(); + exit(-1); } for(i = 1; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ printf("cat: cannot open %s\n", argv[i]); - exit(); + exit(-1); } cat(fd); close(fd); } - exit(); + exit(0); } |