| 203 | } |
| 204 | |
| 205 | static int handle_nonblock(int fd, short poll_events, int err) |
| 206 | { |
| 207 | struct pollfd pfd; |
| 208 | |
| 209 | if (err != EAGAIN && err != EWOULDBLOCK) |
| 210 | return 0; |
| 211 | |
| 212 | pfd.fd = fd; |
| 213 | pfd.events = poll_events; |
| 214 | |
| 215 | /* |
| 216 | * no need to check for errors, here; |
| 217 | * a subsequent read/write will detect unrecoverable errors |
| 218 | */ |
| 219 | poll(&pfd, 1, -1); |
| 220 | return 1; |
| 221 | } |
| 222 | |
| 223 | /* |
| 224 | * xread() is the same a read(), but it automatically restarts read() |