X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=0.0 required=5.0 tests=BAYES_50 X-Spam-Check-By: sourceware.org Date: Tue, 22 Dec 2009 23:43:09 +0100 From: Enrico Forestieri To: cygwin AT cygwin DOT com Subject: select() and named pipes Message-ID: <20091222224309.GA3504@GIOVE> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I am experiencing a problem with select() and named pipes in cygwin 1.7. The attached test case segfaults on the select() call, but works fine with both cygwin 1.5 and linux. -- Enrico --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="selectbug.c" #include #include #include #include #include #include #include #include #define FIFONAME "/tmp/pipe" int main(void) { int fd; int nsel; fd_set readfds; FD_ZERO(&readfds); if (mkfifo(FIFONAME, 0600) < 0) { perror("mkfifo"); exit(1); } fd = open(FIFONAME, O_RDONLY | O_NONBLOCK); if (fd < 0) { perror("open"); remove(FIFONAME); exit(2); } FD_SET(fd, &readfds); do { nsel = select(fd + 1, &readfds, 0, 0, 0); } while (nsel == -1 && (errno == EINTR || errno == EAGAIN)); if (nsel == -1) { perror("select"); exit(3); } if (FD_ISSET(fd, &readfds)) { char buf[100]; int status; while ((status = read(fd, buf, sizeof(buf) - 1))) { if (status > 0) { buf[status] = '\0'; printf("%s", buf); } else { printf("\n"); if (errno != EAGAIN) perror("read"); break; } } } close(fd); remove(FIFONAME); return 0; } --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple --dDRMvlgZJXvWKvBx--