Tim Golden wrote:
Sounds reasonable, but isn't actually true. This works fine:
<code>
import subprocess
open ("t.bat", "w").write ("echo hello")
subprocess.Popen ("t.bat")
</code>
TJG
</div>
Dave Angel wrote:
The docs of Popen() state that it uses CreateProcess() on Windows, so I
didn't even try it.
I only knew because I'd answered a similar question
recently and had simply tried it out!
Thanks for informing me it works. I see now the
COMSPEC manipulation in _execute_child(), but I'm still puzzled. When I
step through, it skips that part because we didn't specify shell= as an
argument. It still had not put the cmd.exe /c into the args variable
when it called CreateProcess(). So is the Python CreateProcess more
than a thin wrapper around Windows version?
Doesn't look like it. And using win32process.CreateProcess from
pywin32 does exactly the same. (Haven't checked their source
but I doubt they're finicking around with the parameters):
<code>
import win32process
open ("t.bat", "w").write ("echo hello")
win32process.CreateProcess (
None,
"t.bat",
None,
None,
1,
0,
None,
None,
win32process.STARTUPINFO ()
)
</code>
gives
<dump>
(<PyHANDLE at 11729792 (128)>, <PyHANDLE at 11042712 (132)>, 6208, 5732)
c:\temp>echo hello
hello
</dump>
So it looks as though the MS docs are simply wrong? I haven't
tried it with ctypes or a native C program, but I can't
see that they should be any different. If I get a chance
later I'll knock something up in C.
But what about the OP problem? I now see it runs okay for me, both
stand-alone and inside Komodo. But he's getting an exception inside
make_inheritable(), which is apparently being passed an invalid handle.
Runs OK for me, in Python 2.6 running under XP, SP3. 2.6.1
(r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)]
Works under python 26/25/24 and the current subversion trunk,
and on 3.1 once I'd modified the input to be a bytes string.
TJG
--
http://mail.python.org/mailman/listinfo/python-list