Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nonblock extension for win32?

0 views
Skip to first unread message

Bill Kelly

unread,
Mar 11, 2005, 2:55:26 PM3/11/05
to
Howdy,

I recall reading that an extension was available for
win32 to provide nonblocking IO support. I've searched
RAA but nothing turned up that sounded quite like what
I thought I remembered reading about.

Is there such a beast? Does it work with pipes?

One of my applications has an unusable feature on windows
at present, because I need a nonblocking way to read from
a pipe returned from popen(). Is there any nonblocking
way to accomplish this in win32 ruby?


Thanks for any help,

Regards,

Bill


Berger, Daniel

unread,
Mar 11, 2005, 3:13:02 PM3/11/05
to

It was never released as a separate package on the RAA. It was a patch
provided by Jean-Francois Nadeau. See ruby-core:3154.

I believe it was merged into CVS already. So, you can either try
building the latest CVS version, or manually apply that patch and
rebuild.

At least, I *think* this patch will fix your problem.

Regards,

Dan

Bill Kelly

unread,
Mar 11, 2005, 4:04:24 PM3/11/05
to
From: "Berger, Daniel" <Daniel...@qwest.com>

> >
> > From: Bill Kelly [mailto:bi...@cts.com]
> >
> > I recall reading that an extension was available for
> > win32 to provide nonblocking IO support. I've searched
> > RAA but nothing turned up that sounded quite like what
> > I thought I remembered reading about.
> >
> > Is there such a beast? Does it work with pipes?
>
> It was never released as a separate package on the RAA. It was a patch
> provided by Jean-Francois Nadeau. See ruby-core:3154.
>
> I believe it was merged into CVS already. So, you can either try
> building the latest CVS version, or manually apply that patch and
> rebuild.

Thanks, . . . Hmm, it seems the last message in the thread
is from Jean-Francois, asking, "What's the status of this patch?"

In any case it *appears* to be a patch that works only for
sockets (which is also useful to me) but not for pipes.

Grrrrr.......... DAMN YOU BILL GATES !!!!!!!!! !!!!! !!!!!!!

Uh, anyway.... :-/

There must be *some* way to do a non-blocking pipe read
on windows...??? (I saw Nobu's io-wait module on RAA,
that would add a #ready? method. Even that might help;
although I don't know if io-wait works on Windows or not.
The download link seems to be broken...)

..I guess I can redesign these parts of my app to use
sockets instead of pipes... It seems to be either that
or hire a small army and find a time machine and go back
to 1980 and force M$FT to adopt a non-crappy kernel
design?

BTW - any win32 gurus know if it's *theoretically* possible
to do a non-blocking pipe read, i.e. on file handle returned
by popen(), even if ruby doesn't support it?


Thanks,

Bill

Berger, Daniel

unread,
Mar 11, 2005, 4:19:30 PM3/11/05
to
> -----Original Message-----
> From: Bill Kelly [mailto:bi...@cts.com]
> Sent: Friday, March 11, 2005 2:04 PM
> To: ruby-talk ML
> Subject: Re: nonblock extension for win32?

<snip>

> There must be *some* way to do a non-blocking pipe read
> on windows...??? (I saw Nobu's io-wait module on RAA,
> that would add a #ready? method. Even that might help;
> although I don't know if io-wait works on Windows or not. The
> download link seems to be broken...)

With the standard Ruby library? Dunno.

However, perhaps win32-pipe can do what you want, though the API will be
different. Oh, and ignore the docs that say asynchronous pipes aren't
supported. Support was added in 0.1.0 - I need to update the docs.

Regards,

Dan


Bill Kelly

unread,
Mar 11, 2005, 5:51:22 PM3/11/05
to
From: "Berger, Daniel" <Daniel...@qwest.com>

>
> From: Bill Kelly [mailto:bi...@cts.com]
>
> > There must be *some* way to do a non-blocking pipe read
> > on windows...??? (I saw Nobu's io-wait module on RAA,
> > that would add a #ready? method. Even that might help;
> > although I don't know if io-wait works on Windows or not. The
> > download link seems to be broken...)
>
> With the standard Ruby library? Dunno.
>
> However, perhaps win32-pipe can do what you want, though the API will be
> different. Oh, and ignore the docs that say asynchronous pipes aren't
> supported. Support was added in 0.1.0 - I need to update the docs.

Cool, thanks. I'll probably go with sockets so my solution
is platform-portable. But you guys seem to be doing fantastic
work on the win32 utils. Do you anticipate that things like
your win32 fork() will become part of the ruby core?


BTW, for completeness in the context of the nonblocking thread,
my planned solution is to make a small wrapper module for spawning
an external process, which can use popen() to run the desired
subprocess, but talk back to the parent process via sockets.

I.e. instead of

io = IO.popen("command...")

do

sock, child_io = socket_popen("command...")

which will have to do something like:

def socket_popen(cmd)
sv = TCPServer.new(0)
sv_port = sv.addr[1]
middleman = IO.popen("ruby -rsocket -e 'in=IO.popen(#{cmd}); " +
"out=TCPSocket.new(%{localhost}, #{sv_port}); " +
"out.puts(line) while(line=in.gets); " +
"in.close; out.close'")
sock = sv.accept # TO-DO: add timeout
sv.close
[sock, middleman]
end


.. Bleah :( And that implementation is only for
reading for the child process, but that's all I need
at present.

And so the idea is:

sock, child_io = socket_popen("command...")

child_io is effectively a dummy as no data will ever
be returned on that pipe, but can be used to obtain
the pid of the child. All the child's output will
come back on sock, which - yay - at least select()
will work on in win32 (and with the earlier mentioned
patch from Jean-Francois Nadeau could even be nonblocking.)

If anyone knows a less ugly way to do what I'm trying to
do above that's platform-portable, please do comment....

Thanks,

Bill


Berger, Daniel

unread,
Mar 14, 2005, 3:50:12 PM3/14/05
to

> -----Original Message-----
> From: Bill Kelly [mailto:bi...@cts.com]

> Sent: Friday, March 11, 2005 3:51 PM
> To: ruby-talk ML
> Subject: Re: nonblock extension for win32?

<snip>


> Cool, thanks. I'll probably go with sockets so my solution
> is platform-portable. But you guys seem to be doing
> fantastic work on the win32 utils. Do you anticipate that
> things like your win32 fork() will become part of the ruby core?

No. At best some of the Win32 Utils packages might be included with the
one-click Installer. There has been some discussion about it, but
nothing has come of it (yet).

Regards,

Dan

Curt Hibbs

unread,
Mar 14, 2005, 4:35:33 PM3/14/05
to
Berger, Daniel wrote:
>
> <snip>
>
> > Cool, thanks. I'll probably go with sockets so my solution
> > is platform-portable. But you guys seem to be doing
> > fantastic work on the win32 utils. Do you anticipate that
> > things like your win32 fork() will become part of the ruby core?
>
> No. At best some of the Win32 Utils packages might be included with the
> one-click Installer. There has been some discussion about it, but
> nothing has come of it (yet).

I would really like to include some/many/all of the win32 utils in the
one-click installer. But I am way over extended. I'll get to it eventually,
but if someone wants to help out it would speed things up.

Curt

Shashank Date

unread,
Mar 14, 2005, 5:20:11 PM3/14/05
to
Hi Curt,

--- Curt Hibbs <cu...@hibbs.com> wrote:

> I would really like to include some/many/all of the
> win32 utils in the
> one-click installer. But I am way over extended.
> I'll get to it eventually,
> but if someone wants to help out it would speed
> things up.

Wonderful ! I will gladly share my NSIS code with you
and even help to integrate it with the Ruby one-click
installer. Just last night, I was thinking about
sending you an email asking about such merger :-)

> Curt

-- shanko



__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/


0 new messages