win32utils-devel@rubyforge.org
2004-Dec-18 10:03 UTC
[Win32utils-devel] Removing COMSPEC from win32-open3
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. :) Comments? Dan __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com