Popen3 on windows

What’s the status of popen3 on windows?

I tried using win32_popen (from RAA) today with the 1.8.1-13 installer,
but it breaks when I try to read from or write to the IO objects.

Does anyone have a good alternative that works on windows? I need to
control an ssh subprocess.

I’m guessing pty and Ara Howard’s “session” are not windows friendly.

Hi,

What’s the status of popen3 on windows?

I tried using win32_popen (from RAA) today with the 1.8.1-13 installer,
but it breaks when I try to read from or write to the IO objects.

Does anyone have a good alternative that works on windows? I need to
control an ssh subprocess.

The Ruby 1.8.1-13 installer was compiled with MS VC++ 7.x.
But the library win32_popen.so was compiled with MS VC++ 6.x.

I uploaded http://home.nownuri.net/~phasis/popen/win32_popen_1.8.1.zip
It includes win32_popen.so comiled with MS VC++7.x.

I want the Ruby distribution include win32_popen library.

Regards,

Park Heesob

Park,

“Park Heesob” phasis@bcline.com wrote in message

I uploaded http://home.nownuri.net/~phasis/popen/win32_popen_1.8.1.zip
It includes win32_popen.so comiled with MS VC++7.x.

I tried compiling this new release using the VC++ 6.0 and I got this error:

···

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\extract_ruby\popen3>ruby extconf.rb
creating Makefile

C:\extract_ruby\popen3>nmake

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

cl -nologo -MD -Zi -O2b2xg- -G6 -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -Ic:
/ruby/lib/ruby/1.8/i386-mswin32 -I. -I. -I./… -I./…/missing -c -Tcwin32_p
open.c
win32_popen.c
cl -nologo -LD -Fewin32_popen.so w9xpopen.obj win32_popen.obj
msvcrt-ruby18.lib oldnames.lib user32.lib advapi32.lib
wsock32.lib -link -incremental:no -debug -opt:ref -opt:icf -dll -libpath:“c
:/ruby/lib” -def:win32_popen-i386-mswin32.def
Creating library win32_popen.lib and object win32_popen.exp
LINK : warning LNK4089: all references to “USER32.dll” discarded by /OPT:REF
w9xpopen.obj : fatal error LNK1202: “C:\extract_ruby\popen3\vc60.pdb” is
missing debugging information for referencing module
NMAKE : fatal error U1077: ‘cl’ : return code ‘0x2’
Stop.

C:\extract_ruby\popen3>

Park Heesob wrote:

I uploaded http://home.nownuri.net/~phasis/popen/win32_popen_1.8.1.zip
It includes win32_popen.so comiled with MS VC++7.x.

Thanks!

I want the Ruby distribution include win32_popen library.

I’ll vote for that.

Btw, is there any reason why the win32_popen method is named distinctly?
Could it be integrated so that the same popen3 calls would work on
windows and other platforms?

Park Heesob wrote:

Hi,

What’s the status of popen3 on windows?

I tried using win32_popen (from RAA) today with the 1.8.1-13 installer,
but it breaks when I try to read from or write to the IO objects.

Does anyone have a good alternative that works on windows? I need to
control an ssh subprocess.

The Ruby 1.8.1-13 installer was compiled with MS VC++ 7.x.
But the library win32_popen.so was compiled with MS VC++ 6.x.

Good to know that. I’ve downloaded the free compiler tools from MS so I
can build extensions to work with 1.8.1-13.

I uploaded http://home.nownuri.net/~phasis/popen/win32_popen_1.8.1.zip
It includes win32_popen.so comiled with MS VC++7.x.

I’m puzzlied, why does VC generate a .so instead of a .dll? Oh well,
ruby seems to load it with no problem.

More significantly, I’m having trouble reading from a pipe:

C:\win32_popen_1.8.1>irb -r win32_popen
irb(main):001:0> pin, pout, perr = IO.win32_popen3(“dir”)
=> [#IO:0x2c2e8f0, #IO:0x2c2e8d8, #IO:0x2c2e8c0]
irb(main):002:0> pout.read
Errno::EBADF: Bad file descriptor
from (irb):2:in `read’
from (irb):2

The equivalent works with Open3.popen3 on linux. Am I doing something wrong?

Hi,

Park,

I tried compiling this new release using the VC++ 6.0 and I got this
error:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\extract_ruby\popen3>ruby extconf.rb
creating Makefile

C:\extract_ruby\popen3>nmake

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

cl -nologo -MD -Zi -O2b2xg- -G6 -I. -Ic:/ruby/lib/ruby/1.8/i386-mswin32 -Ic:

/ruby/lib/ruby/1.8/i386-mswin32 -I. -I. -I./… -I./…/missing -c -Tcwin32_p

open.c
win32_popen.c
cl -nologo -LD -Fewin32_popen.so w9xpopen.obj win32_popen.obj
msvcrt-ruby18.lib oldnames.lib user32.lib advapi32.lib

wsock32.lib -link -incremental:no -debug -opt:ref -opt:icf -dll -libpath:"c

:/ruby/lib" -def:win32_popen-i386-mswin32.def
Creating library win32_popen.lib and object win32_popen.exp
LINK : warning LNK4089: all references to “USER32.dll” discarded by
/OPT:REF
w9xpopen.obj : fatal error LNK1202: “C:\extract_ruby\popen3\vc60.pdb” is
missing debugging information for referencing module
NMAKE : fatal error U1077: ‘cl’ : return code ‘0x2’
Stop.

It is due to w9xpopen.c included for Windows 98.
Retry after remove w9xpopen.c, w9xpopen.obj and *.pdb

Regards,

Park Heesob

Joel VanderWerf wrote:

I’m puzzlied, why does VC generate a .so instead of a .dll? Oh well,
ruby seems to load it with no problem.

It’ll be the generated Makefile that gives .so as file extension.

···

Thu Jan 29 23:11:57 2004 WATANABE Hirofumi eban@xxxxxxxxxxxxxx.org

  • configure.in (DLEXT2): removed. Ruby does not treat
    “.dll” as a extention library anymore.

[…]

Perhaps the need for speed ? Protesting is futile.

daz

Hi,

At Fri, 14 May 2004 05:51:45 +0900,
Joel VanderWerf wrote in [ruby-talk:100179]:

I’m puzzlied, why does VC generate a .so instead of a .dll? Oh well,
ruby seems to load it with no problem.

Because nothing is prefixed to library files on Windows
traditionally, whereas “lib” for Unixes. For instance, iconv
extension library requires external DLL named iconv.dll in
common, it would introduce confusion if the ruby extension also
were have .dll suffix.

···


Nobu Nakada

“Park Heesob” phasis@bcline.com wrote in message

It is due to w9xpopen.c included for Windows 98.
Retry after remove w9xpopen.c, w9xpopen.obj and *.pdb

That worked !
Thanks …

– shanko

Nobu wrote:

Hi,

At Fri, 14 May 2004 05:51:45 +0900,
Joel VanderWerf wrote in [ruby-talk:100179]:

I’m puzzlied, why does VC generate a .so instead of a .dll? Oh well,
ruby seems to load it with no problem.

Because nothing is prefixed to library files on Windows
traditionally, whereas “lib” for Unixes. For instance, iconv
extension library requires external DLL named iconv.dll in
common, it would introduce confusion if the ruby extension also
were have .dll suffix.

Mmm…
sqlite-ruby uses the external sqlite.dll

The extconf has:
create_makefile( “_sqlite” )

and creates _sqlite.dll internal dll (BTW: actually _sqlite.so)

In a script, we say – require ‘sqlite’ …

Ruby finds sqlite.rb (one-liner) before .dll (or .so) which says:

  require '_sqlite'

_sqlite.dll uses sqlite.dll OK.

Link against _sqlite.lib or sqlite.lib OK
… no conflict … everyone’s happy.

sqlite-ruby is built safely, avoiding conflict. It’s slightly
more tricky to set up, but it’s invisible to the user.

···

=========

With the new change, however, I can write a Ruby package called KERNEL32 or USER32 etc. Build will safely create KERNEL32.so and save me from trouble ;))

I distributed a dll made to run with Ruby 1.6 → 1.9 on
Windows only called ___.so and in the FAQ is:

  1. “There’s no dll in the zip file.”
  2. “What’s this ___.so” thing ?

:wink:

But I don’t have a problem with the new setup.
It’s in the Changelog, so I was able to find the information.

daz

Hi,

At Fri, 14 May 2004 12:33:49 +0900,
daz wrote in [ruby-talk:100233]:

I distributed a dll made to run with Ruby 1.6 → 1.9 on
Windows only called ___.so and in the FAQ is:

  1. “There’s no dll in the zip file.”

There should be msvcrt-ruby19.dll :slight_smile:

Actually, suffixes are not important for Windows kernel itself,
just userland programs (Exporler, cmd.exe, etc) mind them. So
you can execute viruses have non-.exe suffixes.

···


Nobu Nakada

Nobu wrote:

At Fri, 14 May 2004 12:33:49 +0900,
daz wrote in [ruby-talk:100233]:

I distributed a dll made to run with Ruby 1.6 → 1.9 on
Windows only called ___.so and in the FAQ is:

  1. “There’s no dll in the zip file.”

There should be msvcrt-ruby19.dll :slight_smile:

They can use their own version of Ruby. I find their runtime
from the return address on the stack and map the few Ruby calls
that I need via GetProcAddress().
(They could have bccwin32-ruby17.dll or others)

Please don’t look :wink:
http://users.hol.gr/~dck/g4c/dll/languages.html (55k)
(Source included - ugly mapping macro is R4.h)

[…]

Nobu Nakada

daz