From: Ville Mattila Date: 2001-11-21T00:32:16+09:00 Subject: [ruby-talk:25914] FIX! for Re: BUG? Solaris select or poll does not recover correctly when signaled Hello, The problem is solved with the following two patches. I'm suprised that now one else hasn't suffered with eval.c:rb_thread_select bug before. At the end the this problem was quite simple to fix. Any Comments? - ville These patches are against of ruby 1.6.5. --- eval.c.orig Tue Nov 20 17:16:20 2001 +++ eval.c Tue Nov 20 17:17:54 2001 @@ -7751,11 +7751,13 @@ n = select(max, read, write, except, tvp); TRAP_END; if (n < 0 && errno == EINTR) { - if (timeout) { - double d = timeofday() - limit; - - tv.tv_sec = (unsigned int)d; - tv.tv_usec = (long)((d-(double)tv.tv_sec)*1e6); + if (timeout) { + double d = limit - timeofday(); + tv.tv_sec = (unsigned int)d; + tv.tv_usec = (long)((d-(double)tv.tv_sec)*1e6); + if (tv.tv_sec < 0 || tv.tv_usec < 0) { + memset(tvp, 0, sizeof(struct timeval)); + } } continue; } --- signal.c.orig Tue Nov 20 17:16:28 2001 +++ signal.c Tue Nov 20 17:20:59 2001 @@ -293,7 +293,13 @@ sigemptyset(&sigact.sa_mask); sigact.sa_flags = 0; #ifdef SA_RESTART - sigact.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ + /* All other signals but VTALRM shall restart restartable syscall + VTALRM will cause EINTR to syscall if interrupted. + */ + if (signum != SIGVTALRM) { + sigact.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */ + } + #endif #ifdef SA_NOCLDWAIT if (signum == SIGCHLD && handler == SIG_IGN)