[Win32utils-devel] Removing COMSPEC from win32-open3

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Sat Dec 18 10:05:07 EST 2004

Hi all,

Aslak brought up a good point with regards to
returning the pid for a popen4() method.  As it stands
now, it returns the pid of the shell rather than the
pid of the process itself.

However, my attempts to remove the COMSPEC stuff
result in CreateProcess() failing with an error code
of 2, i.e. "the system cannot find the file specified"
- not too helpful.  This is when I tried to run the
"ver" command.

(A short while later)

Hmm...it looks like some of these command line apps
are actually dll files, not .exe files (as in the case
of 'ver') that get loaded by cmd.exe.  Ugh.

(Thinking out loud)

Hmm...if you run a command like "ver", then the pid of
the shell would seem to be the proper value.  But if
you run a command like "notepad", then it probably
isn't what you want.

(More thinking out loud)

Try CreateProcess twice.  The first time, call it
without COMSPEC.  If that fails, then try it with
COMSPEC.  Only if the second call fails would it
finally be considered an error.  That still leaves the
SW_HIDE vs. SW_SHOW issue, though.

(Possible solution)

Create an Open3.show_window= method that accepts a
boolean value.  It would be the onus of the programmer
to remember to set this to true if they want to create
a GUI window of some sort using popen3 or popen4.

Ok, I'm done thinking for a little while. :)



Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the win32utils-devel mailing list