From: Frans Kaashoek Date: Mon, 19 Sep 2016 11:01:30 +0000 (-0400) Subject: Check result of write (thans to Alexander Kapshuk 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();