from line 991. This is error handling for initial read. We read till there is no data to read.  So, the last read would return -1 and typically the errno would be EAGAIN. We save that errno and check if it is not an expected error and handle it here.