Date: Fri, 10 Dec 1999 01:52:53 +0100 (MET) From: Gisle Vanem To: djgpp AT Delorie DOT com Subject: select() error Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com I think there is a bug in ./src/libc/compat/time/select.c. The code assumes that select() is always called with a bitset equal to the size of 'fd_set'. E.g. fd_set fd_read; FD_ZERO (&fd_read); int num = select (10, &fd_read, NULL, NULL, NULL); But I've seen code that supports bitset of arbitrary size (infact from 1 to unlimited size). Here the size of 'read' bitset is just large enough to hold the 'fds' of interest. Which normally is less than 256 fds (bits). And with correct typecast of an IN/OUT parameter this is no problem. select.c: /* Exit if we found what we were waiting for. */ if (ready > 0) { if (readfds) *readfds = oread; ^^ This may overwrite users bitset in 'readfds'. Similarily for 'writefds' and 'exceptfds'. Solution would be to loop and set or clear maximum 'nfds' bits. Gisle V.