os.popen() vs os.system()

Gerrit Holl gerrit.holl at pobox.com
Wed Dec 22 09:27:53 EST 1999


Sposhua wrote:
> On Wed, 22 Dec 1999, Gerrit Holl wrote:
> 
> > Sposhua wrote:
> > > a) popen automatically starts a new process while system only does it if you
> > > include an &
> > 
> > Not true:
> > >>> os.getpid()
> > 3264
> > >>> os.system("echo $$")
> > 3658
> 
> !? You are replying to a newbie here ;-) Didn't quite understand the answer...

Sorry.

A process has a unique process ID, pid. If one starts a new process, that
process gets a new process id. "echo $$" is a shell command to echo
the process id to stdout.
So if 'os.system("echo $$")' differs from os.getpid(), you can conclude
that it's not the same process.

Understood?

regards,
Gerrit.

-- 
"The IETF motto is 'rough consensus and running code'"
  
  -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates)
  3:26pm  up  4:21, 16 users,  load average: 0.07, 0.04, 0.05




More information about the Python-list mailing list