Select on solaris

From: Jeff Putsch [mailto:putsch@mxim.com]
Howdy,

I’m trying to use select() with Open3.popen3 on Solaris 8
with ruby 1.6.7.
If it matters ruby was built on Solaris 2.6.

I highly recommend rebuilding Ruby on 2.8. It’s a big enough pain to get
a native build working on Solaris, much less a binary from an older kernel.
That doesn’t seem to be the issue here, however.

It seems that select() is claiming file descriptors are ready
whether or
not they are.

The simple program I’m trying as a test is:

#!/usr/sepp/bin/ruby

require ‘open3’

def run_command
[stdin, out, err] = Open3.popen3(“cat /etc/hosts”)
while not (r=select([out,err])).nil?
yield r.inspect
end
end

This does not seem right. First, there is never any data on the error
object, so why is select saying there is? Second once the end of the
file is reached, why is select continuing to claim both descriptors
have data? I’m sure I’m doing something wrong…

err is in IO object, it’s not the data contained within the object.

To see if err contains an actual error message, just do this:

e = err.gets
if e.nil?

No error

else

kerblooey!

end

Hope that helps.

Regards,

Dan

···

-----Original Message-----