- if ((n = recvmsg(sock, &msg, 0)) == -1)
- fatal("%s: recvmsg: %s", __func__, strerror(errno));
- if (n != 1)
- fatal("%s: recvmsg: expected received 1 got %ld",
+ pfd.fd = sock;
+ pfd.events = POLLIN;
+ while ((n = recvmsg(sock, &msg, 0)) == -1 &&
+ (errno == EAGAIN || errno == EINTR)) {
+ debug3("%s: recvmsg: %s", __func__, strerror(errno));
+ (void)poll(&pfd, 1, -1);
+ }
+ if (n == -1) {
+ error("%s: recvmsg: %s", __func__, strerror(errno));
+ return -1;
+ }
+
+ if (n != 1) {
+ error("%s: recvmsg: expected received 1 got %ld",