cpu: properly handle end of file in readstr()
This commit is contained in:
parent
ee289c2415
commit
7c1e0be919
1 changed files with 4 additions and 0 deletions
|
@ -430,6 +430,10 @@ readstr(int fd, char *str, int len)
|
||||||
n = read(fd, str, 1);
|
n = read(fd, str, 1);
|
||||||
if(n < 0)
|
if(n < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
if(n == 0){
|
||||||
|
werrstr("hung up");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if(*str == '\0')
|
if(*str == '\0')
|
||||||
return 0;
|
return 0;
|
||||||
str++;
|
str++;
|
||||||
|
|
Loading…
Reference in a new issue