Problem with select(2) in single threaded runtime.

Merijn Verstraaten merijn at
Tue Nov 4 17:18:44 UTC 2014

Hi Herbert,

> On 4 Nov 2014, at 0:34, Herbert Valerio Riedel <hvriedel at> wrote:
> Was the passed `timeval` structure valid? I.e. is the tv_usec value inside
> the [0,1e6-1] range? and was tv_sec>=0 ?

The simple test I wrote is:

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <limits.h>
#include <sys/select.h>
#include <sys/time.h>

int main(int argc, char **argv)
    fd_set set;

    struct timeval tv;
    tv.tv_sec = INT_MAX;
    tv.tv_usec = 0;

    FD_SET(0, &set);

    int ret = select(1, &set, &set, &set, &tv);
    printf("Result %d: %s\n", ret, strerror(errno));
    printf("time_t: %lu suseconds_t: %lu\n", sizeof(time_t), sizeof(suseconds_t));
    return 0;

This exits with EINVAL for me on OSX, if I replace INT_MAX with 1000, it runs just fine. The man page on OSX mentions EINVAL for values that exceed the maximum timeout, so it looks like OSX is not following the spec, then...


More information about the ghc-devs mailing list