> I tried that with both the HANDLE value and with an fd value that I
> associate with the HANDLE value using _open_osfhandle. The latter fails with
> EBADF, and the former fails with "the file is not open for writing." I fully
> expected the former, and the latter sounds a bit like the same class of
> problem, where I'm basically bringing in a foreign file descriptor that Ruby
> doesn't really "know about."

Having never done it, it's possible that your "file is not open for
writing" means the fd wasn't transferred across apps successfully.
One thing that might help might be to try and get something working
using straight C first, then attempt its ruby equiv.
Cheers!
-=r