Reputation: 13487
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?
Upvotes: 34
Views: 48647
Reputation: 2763
On Mac it waits, but on Linux it does not (Debian, python 3.7.3).
Fixed using subprocess:
import subprocess
subprocess.run("cmd")
Upvotes: 3
Reputation: 3804
Yes it does. The return value of the call is the exit code of the subprocess.
Upvotes: 37
Reputation: 9569
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.
Upvotes: 15