calling a program without waiting for it to finish
Jp Calderone
exarkun at intarweb.us
Thu Mar 20 12:41:19 EST 2003
On Thu, Mar 20, 2003 at 09:07:42AM -0800, Brian Munroe wrote:
> > the shell interactively, only, of course!-) as soon as it's done
> > setting things up, so the pipeline runs in separate processes.
> >
> > os.system delegates the whole operation to the system shell (normally
> > sh) so the above information should be directly applicable...
> >
>
> So if you enter os.system('ping blah.com &') it will basically shell out
> to the os and run the ping command in the background? If you use ping
> without a -n option (atleast on the machine I am on) it will continue
> to ping forever (or until ^C)
>
> So, do you know if this process terminates when the python script
> finishes, or will it continue to run in the background? If it continues
> to run, this could cause problems.
>
> I would try it, but I don't have access to a python interpeter at the
> moment.
>
Python is the parent of the shell os.system() creates, and so is the
parent of the ping process that shell execvs itself into.
Like any other parent/sibling relationship, the parent disappearing has
negligible effect on the child. The ping will continue to run after Python
disappears.
Check out the commands and popen2 module, these might provide a workable
alternative to os.system().
Jp
--
Examinations are formidable even to the best prepared, for
even the greatest fool may ask more the the wisest man can answer.
-- C.C. Colton
--
up 13:58, 4 users, load average: 0.55, 0.57, 0.47
More information about the Python-list
mailing list