From: Yui NARUSE Date: 2011-11-09T02:10:18+09:00 Subject: [ruby-dev:44842] [ruby-trunk - Bug #5524] IO.wait_for_single_fd(closed fd) sticks on other than Linux Issue #5524 has been updated by Yui NARUSE. Motohiro KOSAKI wrote: > なるせさんのテストプロは selectのmaxfds引数が間違っているので、動かないのは期待通りではないでしょうか。以下の修正をあててFreeBSDで > 動かしてもらえませんか おぉ、なるほど、確かにそれだと FreeBSD だけ動きません。 FreeBSD 側のバグとして報告しました、当面 FreeBSD だけスキップするようにします。 http://www.freebsd.org/cgi/query-pr.cgi?pr=162379 ---------------------------------------- Bug #5524: IO.wait_for_single_fd(closed fd) sticks on other than Linux http://redmine.ruby-lang.org/issues/5524 Author: Yui NARUSE Status: Feedback Priority: Normal Assignee: Yui NARUSE Category: Target version: ruby -v: - r31428 で、test_wait_for_invalid_fd ってテストを追加しており、 IO.wait_for_single_fd(close 済みの fd) が EBADF になることを確認しているのですが、 これ単体で動かすと FreeBSD で戻ってきません。 思うに、このテストって本来ポータブルに刺さる物なんじゃないでしょうか。 test-allだと何かの弾みで通ってしまうだけで。 % cat poll.c #include #include #include #include int main(void) { int pipes[2]; int res = pipe(pipes); if (res != 0) abort(); int r = pipes[0]; int w = pipes[1]; res = close(w); if (res != 0) abort(); struct pollfd fds; fds.fd = w; fds.events = POLLOUT; errno = 0; res = poll(&fds, 1, 1000); fprintf(stderr, "%d %d %d\n", res, errno, fds.revents); return 0; } というプログラムではポータブルに POLLVAL が返り、 #include #include #include int main(void) { int pipes[2]; int res = pipe(pipes); if (res != 0) abort(); int r = pipes[0]; int w = pipes[1]; res = close(w); if (res != 0) abort(); fd_set readfds; FD_ZERO(&readfds); fd_set writefds; FD_ZERO(&writefds); fd_set exceptfds; FD_ZERO(&exceptfds); //struct timeval *timeout = NULL; //FD_SET(r, &readfds); FD_SET(w, &writefds); res = select(1, &readfds, &writefds, &exceptfds, NULL); return 0; } はポータブルにブロックされるあたり、このテストってLinux依存なんじゃ無いかという疑惑を持っているんですがどうでしょう。 -- http://redmine.ruby-lang.org