Commit 89826f41 authored by Frans Kaashoek's avatar Frans Kaashoek
Browse files

Check result of write (thans to Alexander Kapshuk <alexander.kapshuk@gmail)

parent 912575ad
......@@ -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();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment