struct pollfd fds[1]; fds[0].fd = s->fd; fds[0].events = POLLIN; fds[0].revents = 0; res = poll(fds, 1, -1); if (res < 0) { if (errno != EINTR) { log("poll() returned error: %s\n", strerror(errno)); return res; } } if (fds[0].revents) { memset(s->inbuf,0,sizeof(s->inbuf)); res = read(s->fd, s->inbuf, 4); if (res < 0) { log("failed on read() with res=%d, errno=%d", res, errno); return res; } } failed on read() #1 with res=-1, errno=104