It's a very difficult problem that can hardly be solved.

Ruby creates a pthread-level thread when you create a Ruby-level thread
(to catch signals from outer-process things), but what do you think is
the right process for a pthread-level thread being killed when some
other thread of the same process ID calls any execve()-family functions?

Your pthread thread may perhaps is waiting for a mutex, or is reading
from a socket, or needs special cleanups.  You cannot simply
pthread_kill() that thread as that thread can set pthread_sigmask() to
ignore all signals.  You cannot even pthread_cancel() that thread, as
that thread is not always in a cancellation point.

Mac OS X's approach for this is simple: they won't allow it.  Just
throws ENOTSUPP and won't execute any new image.  It's quite
reasonable.  There's handful of problems to do so as I wrote above. 
Linux takes a different approach that they silently scribble out all the
threads with the new image being execve()-ed, but I don't think this is
a right way...

Kent Sibilev wrote:
> Does anyone know how to explain this:
>
> $ irb
>>> exec 'date'
> Wed Mar 14 01:38:11 EDT 2007
> $ irb
>>> Thread.new {}
> => #<Thread:0x3546e8 dead>
>>> exec 'date'
> Errno::EOPNOTSUPP: Operation not supported - date
>        from (irb):2:in `exec'
>        from (irb):2
>        from :0
>>>
>
> I couldn't reproduce it on Linux though.
>