Ruby, Windows XP, and CMD.exe

C

Clark Snowdall

Hello all,

I am developing a SOAP server running on a Windows XP machine. When
contacted from the outside, it will launch a windows executable at the
command line. The problem is this executable takes a long time. When I
would block on the SOAP call I would get a time out error on the client
end, as one would expect.

So when I put the command in a thread it would still cause a timeout
even though it would pass the point of executing the command line app.
It still seems that the method inside the SOAP::RPC::StandaloneServer
blocks until all the threads clear.

I've also tried using the windows "start" command to kick this thing
off. But again, the method blocks until the windows app finishes.

I also tried using exec("my_app.exe") if fork.nil? In that case the
SOAP meothd returns to the client but the windows app is prematurely cut
off before finishing.

Essentially, I need something along the lines of "command &" from unix
for windows. Any ideas?

Thanks in advance,
Snowdall
 
K

Kim Juik

Which one send you 'time out error'? IIS Server ? or Another?

If You use IIS, try to chang option of IIS.
 
A

ara.t.howard

Hello all,

I am developing a SOAP server running on a Windows XP machine. When
contacted from the outside, it will launch a windows executable at the
command line. The problem is this executable takes a long time. When I
would block on the SOAP call I would get a time out error on the client
end, as one would expect.

So when I put the command in a thread it would still cause a timeout
even though it would pass the point of executing the command line app.
It still seems that the method inside the SOAP::RPC::StandaloneServer
blocks until all the threads clear.

I've also tried using the windows "start" command to kick this thing
off. But again, the method blocks until the windows app finishes.

I also tried using exec("my_app.exe") if fork.nil? In that case the
SOAP meothd returns to the client but the windows app is prematurely cut
off before finishing.

Essentially, I need something along the lines of "command &" from unix
for windows. Any ideas?

Thanks in advance,
Snowdall

require 'rubygems'
require 'systemu' # gem install systemu

cmd = 'your.app'

t = Thread.new{ systemu cmd } # run in background

# stuff

status, stdout, stderr = t.value # get info later iff needed


regards.

-a
 
D

David Vallner

--------------enigB1BA25BC22656C5550277973
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Clark said:
I am developing a SOAP server running on a Windows XP machine. When
contacted from the outside, it will launch a windows executable at the
command line. The problem is this executable takes a long time. When = I
would block on the SOAP call I would get a time out error on the client=
end, as one would expect.

How are you launching that process?

system() or `` are Bad Ideas, IO.popen should do what you need.

David Vallner


--------------enigB1BA25BC22656C5550277973
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFfxhzy6MhrS8astoRApprAJwOJnKxZAOmrtZ1PN4XJe06L5U7dgCfVDPX
YfJFB9NUEfpcSSMjKYX1olI=
=p81d
-----END PGP SIGNATURE-----

--------------enigB1BA25BC22656C5550277973--
 
A

ara.t.howard

How are you launching that process?

system() or `` are Bad Ideas, IO.popen should do what you need.

why would say that? IO.popen and more than one thread is a disaster on
windows: if the parent doesn't read from the process fast enough one will end
up with deadlock.

regards.

-a
 
E

Eli Bendersky

Essentially, I need something along the lines of "command &" from unix
for windows. Any ideas?

Perl's "system" function has an undocumented feature that allows you to
call:

system(1, "command");

And the command is run "detached" - in a separate process. Under the
hood, the Win32 CreateProcess function is used. Maybe Ruby's "system"
borrowed the feature ?

Also, Perl's Win32::process module allows to do it more directly. It
also calls CreateProcess under the hood, and you need to provide the
CREATE_NEW_PROCESS_GROUP flag to it in order to "detach". Perhaps
Ruby's equivalent module can be used.

Sorry for the Perl-talk, I'm still not too proficient with Ruby
libraries. Hope this helps, though
 
C

Clark Snowdall

why would say that? IO.popen and more than one thread is a disaster on
windows: if the parent doesn't read from the process fast enough one
will end
up with deadlock.

regards.

-a

IO.popen wins! I tried the systemu first and yes that would return, but
it never actually launched my app. In fact when I made cmd = 'cmd.exe'
it didn't even launch it. I also tried it with cmd = 'START my_app.exe"
but that also didn't work.

But once I tried IO.popen that worked out of the box. Thanks to all who
helped out on this one.

Snowdall
 
D

David Vallner

--------------enigD1CA7F7391BA60FABE2C632B
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

=20
why would say that? IO.popen and more than one thread is a disaster on=
windows: if the parent doesn't read from the process fast enough one
will end
up with deadlock.
=20

I made (unconsciously) a guess that it's a fire-and-forget subprocess,
the simpler case why it would be necessary that it doesn't block the
parent. Seems (from the later followup) I guessed right, but thanks for
bringing that point up for cases when it isn't, I'm admittedly flaky
when it comes to process synchronisation.

David Vallner


--------------enigD1CA7F7391BA60FABE2C632B
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)

iD8DBQFFgFVYy6MhrS8astoRAslvAJ0TrD4e5tBOPlPnJhk+Bkbb1MsaRACfae5o
JwOuSpycrV/bl7IBo9DXdes=
=wRWx
-----END PGP SIGNATURE-----

--------------enigD1CA7F7391BA60FABE2C632B--
 

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,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top