Merge branch 'nd/exclusion-regression-fix'
[gitweb.git] / wrapper.c
index 6fcaa4dc62b504078ea5202cfd7a096e79a83c5e..b43d437630c9245a6a48a0940df1607e21357362 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -236,8 +236,24 @@ ssize_t xread(int fd, void *buf, size_t len)
            len = MAX_IO_SIZE;
        while (1) {
                nr = read(fd, buf, len);
-               if ((nr < 0) && (errno == EAGAIN || errno == EINTR))
-                       continue;
+               if (nr < 0) {
+                       if (errno == EINTR)
+                               continue;
+                       if (errno == EAGAIN || errno == EWOULDBLOCK) {
+                               struct pollfd pfd;
+                               pfd.events = POLLIN;
+                               pfd.fd = fd;
+                               /*
+                                * it is OK if this poll() failed; we
+                                * want to leave this infinite loop
+                                * only when read() returns with
+                                * success, or an expected failure,
+                                * which would be checked by the next
+                                * call to read(2).
+                                */
+                               poll(&pfd, 1, -1);
+                       }
+               }
                return nr;
        }
 }
@@ -601,18 +617,6 @@ int access_or_die(const char *path, int mode, unsigned flag)
        return ret;
 }
 
-struct passwd *xgetpwuid_self(void)
-{
-       struct passwd *pw;
-
-       errno = 0;
-       pw = getpwuid(getuid());
-       if (!pw)
-               die(_("unable to look up current user in the passwd file: %s"),
-                   errno ? strerror(errno) : _("no such user"));
-       return pw;
-}
-
 char *xgetcwd(void)
 {
        struct strbuf sb = STRBUF_INIT;