Does Python's os.system() wait for an end of the process?
Question:
The Python manual says nothing about whether os.system("cmd")
waits or not for a process to end:
To quote the manual:
Execute the command (a string) in a subshell.
It looks like it does wait (same behaviour as Perl’s system
). Is this correct?
Answers:
The manual doesn’t explicitly say, but it does imply that it waits for the end of the process by saying that the return value is the return value of the program.
So to answer your question, yes it does wait.
Yes it does. The return value of the call is the exit code of the subprocess.
On Mac it waits, but on Linux it does not (Debian, python 3.7.3).
Fixed using subprocess:
import subprocess
subprocess.run("cmd")
The Python manual says nothing about whether os.system("cmd")
waits or not for a process to end:
To quote the manual:
Execute the command (a string) in a subshell.
It looks like it does wait (same behaviour as Perl’s system
). Is this correct?
The manual doesn’t explicitly say, but it does imply that it waits for the end of the process by saying that the return value is the return value of the program.
So to answer your question, yes it does wait.
Yes it does. The return value of the call is the exit code of the subprocess.
On Mac it waits, but on Linux it does not (Debian, python 3.7.3).
Fixed using subprocess:
import subprocess
subprocess.run("cmd")