while (1) { n = read(fd, buf, BUFSIZ); if (n == -1 && errno != EINTR) { printf("read error\n"); break; } if (n == 0) { printf("read done\n"); break; } }