- if ((bufpos & 0xff) == 0)
- buffer = xrealloc(buffer, bufpos + 0x100);
- if (nonblock_safe_read(fd, &buffer[bufpos], 1) != 1) {
+ /* We must poll even if timeout is -1:
+ * we want to be interrupted if signal arrives,
+ * regardless of SA_RESTART-ness of that signal!
+ */
+ errno = 0;
+ pfd[0].fd = fd;
+ pfd[0].events = POLLIN;
+ if (poll(pfd, 1, timeout) != 1) {
+ /* timed out, or EINTR */
+ err = errno;
+ retval = (const char *)(uintptr_t)1;
+ goto ret;
+ }
+ if (read(fd, &buffer[bufpos], 1) != 1) {
+ err = errno;