programs exit?
Mark McEahern
marklists at mceahern.com
Fri Jan 18 18:04:23 EST 2002
maximilianscherr wrote:
> how can i know if a program i started from the script has exitted?
>
> by using spwanv() to start it? how exactly do i get to know this?
Short answer: os.waitpid()
Here's an example:
import os
def spawnCommand(command, args):
"""Spawn the command and return the process id."""
pid = os.spawnv(os.P_NOWAIT, command, args)
return pid
command = "ls"
args = ['foo']
pid = spawnCommand(command, args) # args is a list
result = os.waitpid(pid, 0)
// mark
More information about the Python-list
mailing list