getpid Usage

Martin Carpenter mcarpenter at free.fr
Fri Jul 14 11:04:29 EDT 2000


Gregoire Welraeds wrote:

> You should have a look at the os.fork() function which is  python
> "translation" of the fork system call (availability Unix).
[snip]
> i= os.fork()    # Create the new process
> 
> if i != 0:      # If i != 0, we are in the parent process
>         print 'Forked process as the pid : ', i
> else:           # We are in the child process
>         os.system('ls -la')

But I think the original question requires use of one of the os.exec*
family rather than os.system - that way you're sure to know the PID of
the eventual target program and not the PID of the child process that
calls the target program, which isn't the same thing...

Martin.




More information about the Python-list mailing list