Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Python's os.system() wait for an end of the process?

Tags:

python

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?

like image 472
Adobe Avatar asked Nov 23 '11 17:11

Adobe


People also ask

Does OS system wait until finish?

Answer #1: os. system() does wait for its process to complete before returning. If you are seeing it not wait, the process you are launching is likely detaching itself to run in the background in which case the subprocess.

What does OS wait () do?

wait() method in Python is used by a process to wait for completion of a child process. This method returns a tuple containing its PID and exit status indication.

What does OS system return in Python?

The os. system() function executes a command, prints any output of the command to the console, and returns the exit code of the command.


1 Answers

Yes it does. The return value of the call is the exit code of the subprocess.

like image 114
Russel Winder Avatar answered Sep 20 '22 02:09

Russel Winder