(wiseman303) #1

How can I tell when a program opened with popen or popen2 has closed? I want to open one program, and then open a different one when the first closes.

Could somebody please tell me how this is done?

(eeshlo) #2

You might already know this, so this might be useless unformation but unless you really need popen to read output of the program, using the os.spawn commands allow you to wait for the program to exit, for instance:

cmd = full_path_to_program_to_execute
args = arguments_to_program
os.spawnv(os.P_WAIT, cmd, (cmd, args))

use os.P_NOWAIT to immediately return when the program has started.

(wiseman303) #3

Thanks so much eeshlo, that is exactly what I was looking for. :slight_smile: