Program chaining on Windows

Rob Cliffe rob.cliffe at btinternet.com
Mon Aug 24 03:16:10 EDT 2020



On 24/08/2020 00:08, Eryk Sun wrote:
>
> For Windows, we need to spawn, wait, and proxy the exit status.
Sorry, I understand very little of this.  Here's where I get stuck:
     (1) "*spawn*": I see that there are some os.spawn* functions.  I 
tried this:

     # File X1.py
     import os, sys
     print("This is X1")
     pid = os.spawnl(os.P_NOWAIT, "C:\\Python38\\python.exe", 
"C:\\Python38\\X2.py")
     print(f"X1 got {pid=}")
     sys.exit()

but when I ran it, it displayed

     This is X1
     X1 got pid=...

and then apparently started the Python interactive interpreter, although 
in reality things were in one of the confused states that I described in 
my first post.
(FWIW If I type
     "C:\\Python38\\python.exe" "C:\\Python38\\X2.py"
from the DOS prompt, it works as expected.)

     (2) "*wait*": Wait for what?  How?
     (3) "*proxy the exit status*": Sorry, I have no idea what this means.

Are you suggesting something I could do in Python that would achieve my 
aim of *replacing* one program by another (or merely e.g. describing 
something you could do in C)?
If so, is there any chance you could give me some toy code?
As you can see, I'm pretty well lost.

Thanks again
Rob Cliffe


More information about the Python-list mailing list