It seems that rb_thread_wait_fd() doesn't work in 1.8.6

Here is a test:
http://s3.amazonaws.com/four.livejournal/20080316/rb_thread_wait_fd.tar.gz

compile it: ruby extconf.rb && make
run it: ruby test.rb

it should not exit.

Ruby 1.9.0 has the correct behavior, but 1.8.6 exits immediately.

Is this a bug? Probably not - what am I doing wrong?

thanks, ry

it should not exit.

Why ?

vgs% cat a.c
#include <stdio.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <assert.h>

int main()
{
    fd_set readfds;
    int fd = socket(AF_INET, SOCK_STREAM, 0);
    assert(fd > 0);
    FD_ZERO(&readfds);
    FD_SET(fd, &readfds);
    select(fd + 1, &readfds, 0, 0, NULL);
    return 0;
}
vgs%

vgs% ./a.out
vgs%

Ruby 1.9.0 has the correct behavior

what is your version of ruby ?

vgs% ruby -v test.rb
ruby 1.9.0 (2008-03-16 revision 15786) [i686-linux]
starting test
entering rb_thread_wait_fd
leaving rb_thread_wait_fd
vgs%

Guy Decoux

Hi,

At Sun, 16 Mar 2008 23:40:00 +0900,
ry wrote in [ruby-talk:294753]:

Is this a bug? Probably not - what am I doing wrong?

It doesn't block at EOF.

ยทยทยท

--
Nobu Nakada