commit e066b12927b496c9f3b442a5928bacfb48e6334e from: Michael Teichgräber date: Sun Aug 23 17:25:44 2009 UTC rc: make read not ignore interrupts/errors (again) http://codereview.appspot.com/110042 commit - 375b78fb110b7e1dd3686bc43aba38cf45c606e9 commit + e066b12927b496c9f3b442a5928bacfb48e6334e blob - d71cbc38d1b47e2b5e23c29186657cc99560fe2f blob + 9393fb23e98d14bf87c0265199d069085474740f --- src/cmd/rc/unixcrap.c +++ src/cmd/rc/unixcrap.c @@ -222,8 +222,11 @@ readnb(int fd, char *buf, long cnt) int flgs; didreset = 0; - while((n = read(fd, buf, cnt)) == -1) - if(!didreset && errno == EAGAIN){ +again: + n = read(fd, buf, cnt); + if(n == -1) + if(errno == EAGAIN){ + if(!didreset){ if((flgs = fcntl(fd, F_GETFL, 0)) == -1) return -1; flgs &= ~O_NONBLOCK; @@ -231,6 +234,8 @@ readnb(int fd, char *buf, long cnt) return -1; didreset = 1; } + goto again; + } return n; }