X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.0 c=1 a=fwpaQrO9LTYA:10 a=kCKDY91tEBMc+hi4YtGk8Q==:17 a=FItjtNpJzI5cpGGfTKAA:9 a=1W_MUbLtbCLv21YN8DSaaP0pUL0A:4 Message-ID: <4B6E470D.9080607@monai.ca> Date: Sat, 06 Feb 2010 20:52:29 -0800 From: Steven Monai User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: poll() on fifo read descriptor with non-zero timeout ==> segfault Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes 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 Hi folks, Here is a short test case I've named "fifo-read.c": #include #include #include #include #include #include struct pollfd pfd[1]; int main() { int fifo; int poll_result; int timeout; /* Open myfifo for reading, non-blocking. */ fifo = open("myfifo", O_RDONLY | O_NDELAY); if (-1 == fifo) { perror("open(\"myfifo\", O_RDONLY | O_NDELAY) failed"); return 1; } /* Set up data for poll(). */ pfd[0].fd = fifo; pfd[0].events = POLLIN; pfd[0].revents = 0; timeout = -1; fprintf(stderr, "About to enter poll()\n"); fflush(stderr); poll_result = poll(pfd, 1, timeout); fprintf(stderr, "Just returned from poll()\n"); fflush(stderr); switch (poll_result) { case -1: perror("poll(pfd, 1, timeout) failed"); return 2; case 0: fprintf(stderr, "Timed out?!\n"); return 3; } /* At this point, read() should work. */ return 0; } Here's what happens at the command line: $ uname -a CYGWIN_NT-5.1 lonestar 1.7.1(0.218/5/3) 2009-12-07 11:48 i686 Cygwin $ gcc-4 -Wall -Werror -ansi -pedantic -o fifo-read fifo-read.c $ mkfifo -m0600 myfifo $ ls -l total 29 -rw-r--r--+ 1 steve None 939 2010-02-06 20:25 fifo-read.c -rwxr-xr-x+ 1 steve None 22792 2010-02-06 20:25 fifo-read.exe prw------- 1 steve None 0 2010-02-06 20:25 myfifo $ ./fifo-read About to enter poll() Segmentation fault (core dumped) If I change the timeout to a positive number, it also segfaults. If I change the timeout to zero, it works, but poll() returns immediately with no descriptor ready to read. Not very useful. I get identical results on two different machines, with two different OSes (XP and 2000). Can anyone else reproduce this? Am I using poll() incorrectly? Thanks, -SM -- -- 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