From: Paul Brannan Date: 2006-06-23T00:22:16+09:00 Subject: Re: C Threads and Ruby On Wed, Jun 21, 2006 at 05:17:15AM +0900, Patrick Hurley wrote: > against a Win32 API that required the use of threads. Now I am curious > about TRAP_BEG/TRAP_END. Is it safe to access rb_XXX methods from > inside a TRAP_BEG/TRAP_END block not in the ruby interpreter thread? > If so that would make some things much easier. What goes between TRAP_BEG/TRAP_END should be something that returns in the event of a signal (such as SIGVTALRM, which ruby uses to know when to switch threads). Usually system calls will return an error code and set errno to EINTR. The system call must later be restarted when control returns to the thread. I don't believe most rb_XXX methods have this behavior, so you won't get the magic thread switching you get with system calls. Paul