summaryrefslogtreecommitdiff
path: root/user/cat.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2020-08-10 13:05:17 -0400
committerGitHub <[email protected]>2020-08-10 13:05:17 -0400
commitc31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9 (patch)
treea6c903e1c61c08f4cb87700c320752a737081dcb /user/cat.c
parent90eb90b5e203299427c3fde8c996a48835fc93cf (diff)
parentd8fe1773b26758c7c7b8f36724cd822555b33612 (diff)
downloadxv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.tar.gz
xv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.tar.bz2
xv6-labs-c31d35d8031c88b7e1ea8657cc9806dfdd4c3ef9.zip
Merge branch 'riscv' into riscv
Diffstat (limited to 'user/cat.c')
-rw-r--r--user/cat.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/user/cat.c b/user/cat.c
index 36939d8..598f005 100644
--- a/user/cat.c
+++ b/user/cat.c
@@ -11,12 +11,12 @@ cat(int fd)
while((n = read(fd, buf, sizeof(buf))) > 0) {
if (write(1, buf, n) != n) {
- printf("cat: write error\n");
+ fprintf(2, "cat: write error\n");
exit(1);
}
}
if(n < 0){
- printf("cat: read error\n");
+ fprintf(2, "cat: read error\n");
exit(1);
}
}
@@ -28,12 +28,12 @@ main(int argc, char *argv[])
if(argc <= 1){
cat(0);
- exit(1);
+ exit(0);
}
for(i = 1; i < argc; i++){
if((fd = open(argv[i], 0)) < 0){
- printf("cat: cannot open %s\n", argv[i]);
+ fprintf(2, "cat: cannot open %s\n", argv[i]);
exit(1);
}
cat(fd);