diff options
| author | Frans Kaashoek <kaashoek@mit.edu> | 2016-09-19 07:01:30 -0400 | 
|---|---|---|
| committer | Frans Kaashoek <kaashoek@mit.edu> | 2016-09-19 07:01:30 -0400 | 
| commit | 89826f41bd5c96e6b13692d03d08049c912b9365 (patch) | |
| tree | e8e5b12bb918302cd18f6889718ee359e1b33632 | |
| parent | 912575ad12b7eacc2b0074e3a91843debd52d5f9 (diff) | |
| download | xv6-labs-89826f41bd5c96e6b13692d03d08049c912b9365.tar.gz xv6-labs-89826f41bd5c96e6b13692d03d08049c912b9365.tar.bz2 xv6-labs-89826f41bd5c96e6b13692d03d08049c912b9365.zip | |
Check result of write (thans to Alexander Kapshuk <alexander.kapshuk@gmail)
| -rw-r--r-- | cat.c | 8 | 
1 files changed, 6 insertions, 2 deletions
| @@ -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(); | 
