[Python-Dev] Console vs. GUI applications

Michael Walter michael.walter at gmail.com
Thu Sep 9 11:32:44 CEST 2004


I guessed CMD.EXE would run ShellExecute(), to which you can pass a
filename such as "foo.py". Didn't verify this tho :)

Cheers,
Michael


On Thu, 9 Sep 2004 09:56:00 +0100, Moore, Paul
<paul.moore at atosorigin.com> wrote:
> From: "Martin v. Löwis"
> >Thomas Heller wrote:
> >> It seems to be a flag in the exe header.  A quick google search turned
> >> up this:
> >>
> >> http://www.codeguru.com/Cpp/W-P/system/misc/article.php/c2897/
> >
> > Sure. However, if I do
> >
> > foo.py
> >
> > then some part of the system must determine that python.exe is
> > to be invoked, and then must determine that this is a console
> > binary. Does that all happen in cmd.exe?
> 
> I believe so. The relevant Windows API call is CreateProcess, which
> only handles EXEs (and maybe some obscure cases like COM and PIF files).
> Everything else gets done in user code (in this case CMD.EXE).
> 
> So CMD.EXE runs CreateProcess on your launcher.exe. CreateProcess checks
> a flag (the "subsystem") in the executable header, and acts dependent on
> that. For a "console" executable, it leaves the new process attached to
> the current console (the one CMD.EXE is using) and for a "windows"
> executable, it detaches the process from any console. (Default behaviour
> - there are flags which can affect this).
> 
> I can't work out how CMD.EXE "knows" to wait for a child process to release
> the console (immediately for a windows process, when it terminates for a
> console process) but clearly it does... A test shows that it *is* possible
> for two console processes to share the console. The result is an unusable
> mess, though, so we should be glad cmd.exe does avoid this :-)
> 
> Paul.
> 
> __________________________________________________________________________
> This e-mail and the documents attached are confidential and intended
> solely for the addressee; it may also be privileged. If you receive this
> e-mail in error, please notify the sender immediately and destroy it.
> As its integrity cannot be secured on the Internet, the Atos Origin group
> liability cannot be triggered for the message content. Although the
> sender endeavours to maintain a computer virus-free network, the sender
> does not warrant that this transmission is virus-free and will not be
> liable for any damages resulting from any virus transmitted.
> __________________________________________________________________________
> 
> 
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/michael.walter%40gmail.com
>


More information about the Python-Dev mailing list