Last active
February 3, 2016 21:51
-
-
Save NoahDragon/758b69871a48eef3d13b to your computer and use it in GitHub Desktop.
Reading all the bytes from file-- from book "Linux System Programming"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Snippet from: Linux System Programming | |
Purpose: read file to avoid system interuption | |
Relative: Nonblocking reads | |
*/ | |
ssize_t ret; | |
while (len != 0 && (ret = read (fd, buf, len)) != 0 ) { | |
if(ret == -1){ | |
if(errno == EINTR) | |
continue; | |
perror("read"); | |
break; | |
} | |
len -= ret; | |
buf += ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment