popen3 on windows

J

Joel VanderWerf

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.
 
P

Park Heesob

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
 
S

Shashank Date

Park,

Park Heesob said:
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>
------------------------------------------------------
 
P

Park Heesob

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
 
S

Shashank Date

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

That worked !
Thanks ...

-- shanko
 
J

Joel VanderWerf

Park said:
Hi,



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?
 
D

daz

Joel said:
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.

<changelog>
----------------------------------------------------------------------
Thu Jan 29 23:11:57 2004 WATANABE Hirofumi <[email protected]>

* configure.in (DLEXT2): removed. Ruby does not treat
".dll" as a extention library anymore.

[...]
----------------------------------------------------------------------

Perhaps the need for speed ? Protesting is futile.


daz
 
N

nobu.nokada

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.
 
D

daz

Nobu said:
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.

=========

<duck>
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 ;))
</duck>

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 ?

;-)

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
 
N

nobu.nokada

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 :)

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.
 
D

daz

Nobu said:
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 :)

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 ;)
http://users.hol.gr/~dck/g4c/dll/languages.html (55k)
(Source included - ugly mapping macro is R4.h)


daz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,373
Latest member
Desiree036

Latest Threads

Top