IO.read not working inside a win32-service

Hi All,

Encountered a strange phenomena with IO.read(IO methods) in a
win32-service.

I am working on Apache Thrift API creation. Firstly for testing purposes
I had created a relay test server on the console(Have to cntrl C to stop
it).

My server uses some commands to be run on it and send the output to the
client. I have implemented this with the win32-open3 gem, with which I
can capture the stdin, stdout, stderr and the pin as well and send these
across to the client.

In the relay test server, the client is able to successfully get
connected to the server, run the command and return the output. Note
that the open3 returns all the stdin, stdout and stderr in nice IO
objects. I have to “.read”(or “.gets”) them to get the actual
information inside them.


Here comes the obstacle.

Now I have created a daemon and a win32-service which runs this server
as a Windows service. The server gets started as expected. But, when the
client when tries to execute the command on the server, the server hangs
:frowning:

A little bit of logging pointed at the IO.read line. Somehow the
stderr.read(or infact the stdout) seems to get lost in an infinite loop
never comming out.

stdin, stdout, stderr, pid = Open3.popen3(command_to_be_executed)
error = stderr.read #(IO Object)
output = stdout.read #(IO Object)

Something strange is happening with the IO stuff in a win32-service.

Somebody please help me out in this. :slight_smile:

Sandy