Hi Paolo, While looking at tests/test-select.c for the OSF/1 failure, I found a couple of small tweaks. Can you agree to these 4 patches?
1) The code for pipe() on Win32 is now in module 'pipe-posix'. And 'pipe-posix' depends on 'unistd'. 2010-12-24 Bruno Haible <br...@clisp.org> select tests: Use existing modules. * modules/select-tests (Depends-on): Add pipe-posix, unistd. (configure.ac): Don't test for unistd.h. * tests/test-select.c: Include <unistd.h> always. Use pipe() as declared in <unistd.h>. --- modules/select-tests.orig Sat Dec 25 01:33:20 2010 +++ modules/select-tests Sat Dec 25 01:33:15 2010 @@ -11,11 +11,13 @@ stdbool netinet_in arpa_inet +unistd sys_ioctl extensions inet_pton errno perror +pipe-posix socket bind setsockopt @@ -27,7 +29,7 @@ gettimeofday configure.ac: -AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h]) +AC_CHECK_HEADERS_ONCE([sys/wait.h]) Makefile.am: TESTS += test-select test-select-in.sh test-select-out.sh --- tests/test-select.c.orig Sat Dec 25 01:33:20 2010 +++ tests/test-select.c Sat Dec 25 01:32:02 2010 @@ -42,6 +42,7 @@ #include <string.h> #include <netinet/in.h> #include <arpa/inet.h> +#include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <stdbool.h> @@ -56,25 +57,18 @@ # define WIN32_NATIVE #endif -#ifdef WIN32_NATIVE -#include <io.h> -#define pipe(x) _pipe(x, 256, O_BINARY) -#endif -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif #ifdef HAVE_SYS_WAIT_H -#include <sys/wait.h> +# include <sys/wait.h> #endif #ifndef SO_REUSEPORT -#define SO_REUSEPORT SO_REUSEADDR +# define SO_REUSEPORT SO_REUSEADDR #endif #define TEST_PORT 12345 2) The arguments passed to function connect_to_socket() are true and false. So it's actually a 'bool' argument. 2010-12-24 Bruno Haible <br...@clisp.org> select tests: Use 'bool' where appropriate. * tests/test-select.c (connect_to_socket): Change argument type to 'bool'. --- tests/test-select.c.orig Sat Dec 25 01:33:20 2010 +++ tests/test-select.c Sat Dec 25 01:32:02 2010 @@ -134,7 +126,7 @@ } static int -connect_to_socket (int blocking) +connect_to_socket (bool blocking) { int s; struct sockaddr_in ia; 3) Because at least some Linux versions return in the timeout parameter the unslept time (see <http://linux.die.net/man/2/select>), it is good practice to not reuse a 'struct timeval' from a previous select() call for the next select() call. Even though in this case the unslept time is probably always zero, better use the safe way of coding. 2010-12-24 Bruno Haible <br...@clisp.org> select tests: Safer way of handling timeout. * tests/test-select.c (do_select_nowait): Zero-initialize the timeout at every invocation. --- tests/test-select.c.orig Sat Dec 25 01:33:20 2010 +++ tests/test-select.c Sat Dec 25 01:32:02 2010 @@ -210,7 +212,9 @@ static int do_select_nowait (int fd, int ev) { - static struct timeval tv0; + struct timeval tv0; + tv0.tv_sec = 0; + tv0.tv_usec = 0; return do_select (fd, ev, &tv0); } 4) A couple of comments for do_select(), since this function is used in all the tests. (The reader may not be familiar with poll().) 2010-12-24 Bruno Haible <br...@clisp.org> select tests: Improve comments. * tests/test-select.c (do_select): Add comments. --- tests/test-select.c.orig Sat Dec 25 01:33:20 2010 +++ tests/test-select.c Sat Dec 25 01:32:02 2010 @@ -50,8 +51,6 @@ #include "macros.h" -enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 }; - #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ # define WIN32_NATIVE #endif @@ -171,10 +163,20 @@ } -/* A slightly more convenient interface to select(2). */ +/* A slightly more convenient interface to select(2). + Waits until a specific event occurs on a file descriptor FD. + EV is a bit mask of events to look for: + SEL_IN - input can be polled without blocking, + SEL_OUT - output can be provided without blocking, + SEL_EXC - an exception occurred, + A maximum wait time is specified by TIMEOUT. + *TIMEOUT = { 0, 0 } means to return immediately, + TIMEOUT = NULL means to wait indefinitely. */ + +enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 }; static int -do_select (int fd, int ev, struct timeval *tv) +do_select (int fd, int ev, struct timeval *timeout) { fd_set rfds, wfds, xfds; int r, rev; @@ -188,7 +190,7 @@ FD_SET (fd, &wfds); if (ev & SEL_EXC) FD_SET (fd, &xfds); - r = select (fd + 1, &rfds, &wfds, &xfds, tv); + r = select (fd + 1, &rfds, &wfds, &xfds, timeout); if (r < 0) return r; @@ -221,7 +225,7 @@ } -/* Test poll(2) for TTYs. */ +/* Test select(2) for TTYs. */ #ifdef INTERACTIVE static void @@ -242,7 +246,7 @@ #endif -/* Test poll(2) for unconnected nonblocking sockets. */ +/* Test select(2) for unconnected nonblocking sockets. */ static void test_connect_first (void) @@ -271,7 +275,7 @@ } -/* Test poll(2) for unconnected blocking sockets. */ +/* Test select(2) for unconnected blocking sockets. */ static void test_accept_first (void) @@ -337,7 +341,7 @@ } -/* Test poll(2) on connected sockets. */ +/* Test select(2) on connected sockets. */ static void test_socket_pair (void) @@ -358,7 +362,7 @@ } -/* Test poll(2) on pipes. */ +/* Test select(2) on pipes. */ static void test_pipe (void)