summaryrefslogtreecommitdiff
path: root/cat.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2016-09-19 07:01:30 -0400
committerFrans Kaashoek <[email protected]>2016-09-19 07:01:30 -0400
commit89826f41bd5c96e6b13692d03d08049c912b9365 (patch)
treee8e5b12bb918302cd18f6889718ee359e1b33632 /cat.c
parent912575ad12b7eacc2b0074e3a91843debd52d5f9 (diff)
downloadxv6-labs-89826f41bd5c96e6b13692d03d08049c912b9365.tar.gz
xv6-labs-89826f41bd5c96e6b13692d03d08049c912b9365.tar.bz2
xv6-labs-89826f41bd5c96e6b13692d03d08049c912b9365.zip
Check result of write (thans to Alexander Kapshuk <alexander.kapshuk@gmail)
Diffstat (limited to 'cat.c')
-rw-r--r--cat.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/cat.c b/cat.c
index 2b2dcc7..5ddc820 100644
--- a/cat.c
+++ b/cat.c
@@ -9,8 +9,12 @@ cat(int fd)
{
int n;
- while((n = read(fd, buf, sizeof(buf))) > 0)
- write(1, buf, n);
+ while((n = read(fd, buf, sizeof(buf))) > 0) {
+ if (write(1, buf, n) != n) {
+ printf(1, "cat: write error\n");
+ exit();
+ }
+ }
if(n < 0){
printf(1, "cat: read error\n");
exit();