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
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/select.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #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; }
-- 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