From: Knutaf Date: 2009-06-12T17:19:07+09:00 Subject: [ruby-core:23815] inheriting socket in child process on native Windows This is a multi-part message in MIME format. ------=_NextPart_000_0154_01C9EAFB.0E907990 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello, In my Ruby application, I accept TCP connections from several clients. When any client sends a particular command, I want to perform a "live reboot" in which I re-launch the Ruby interpreter against the source of the server, picking up any code changes that I've made, without disconnecting any of the clients. So for that reason and because I'd really like this scenario to work on native Windows (no cygwin), I can't use fork(). This works on Linux by persisting socket.fileno from the parent process and calling TCPSocket.for_fd in the child process. On Windows, some tweaks to this approach (wrapping _get_osfhandle and _open_osfhandle) will get me most of the way there, but still falls a little short. I've done enough debugging to point out the code/design in the Ruby source that is causing this failure, in case you'd like me to explain. I'm not committed to this approach, but I haven't been able to think of another one. Is this a scenario that just flat out will not or cannot be supported on Windows? I've been able to get this nearly working, and it's definitely possible to do this with straight C++ on Windows, so it shouldn't be a technical limitation. Or can someone think of another approach to do this? Thanks -K ------=_NextPart_000_0154_01C9EAFB.0E907990 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello,

 

In my Ruby application, I accept TCP connections from several clients. When = any client sends a particular command, I want to perform a “live reboot” in which I re-launch the Ruby interpreter against the = source of the server, picking up any code changes that I’ve made, without disconnecting any of the clients. So for that reason and because = I’d really like this scenario to work on native Windows (no cygwin), I = can’t use fork().

 

This works on Linux by persisting socket.fileno from the parent process and = calling TCPSocket.for_fd in the child process. On Windows, some tweaks to this = approach (wrapping _get_osfhandle and _open_osfhandle) will get me most of the = way there, but still falls a little short. I’ve done enough debugging = to point out the code/design in the Ruby source that is causing this = failure, in case you’d like me to explain. I’m not committed to this = approach, but I haven’t been able to think of another = one.

 

Is this a scenario that just flat out will not or cannot be supported on = Windows? I’ve been able to get this nearly working, and it’s = definitely possible to do this with straight C++ on Windows, so it shouldn’t = be a technical limitation.

 

Or can someone think of another approach to do this?

 

Thanks

-K

------=_NextPart_000_0154_01C9EAFB.0E907990--