I have created a program that creates a web architecture in a local server then loads the necessary browser to display the html and php pages on localhost.
The
The difference between os.system
and subprocess.Popen
is that Popen actually opens a pipe, and os.system
starts a subshell, much like subprocess.call
. Windows only half-supports some pipe/shell features of what *nix operating systems will, but the difference should still fundamentally be the same. A subshell doesn't let you communicate with the standard input and output of another process like a pipe does.
What you probably want is to use subprocess like you are, but then call the kill() method (from the docs) on the pipe object before your application terminates. That will let you decide when you want the process terminated. You might need to satisfy whatever i/o the process wants to do by calling pipe.communicate()
and closing the pipe's file handles.