programs exit?

maximilianscherr MaximilianScherr at T-Online.de
Sat Jan 19 06:32:55 EST 2002


Thanks but hmmm, doesn't work:)
I'm using windows:( how can i get to know when a program exits there?


--- In python-list at y..., "Mark McEahern" <marklists at m...> wrote:
> 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
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list