How to tell process id within Python

Posted by R S on Stack Overflow See other posts from Stack Overflow or by R S
Published on 2010-05-21T18:49:50Z Indexed on 2010/05/22 15:30 UTC
Read the original article Hit count: 237

Filed under:
|
|

Hey,

I am working with a cluster system over linux (www.mosix.org) that allows me to run jobs and have the system run them on different computers. Jobs are run like so:

mosrun ls &

This will naturally create the process and run it on the background, returning the process id, like so:

[1] 29199

Later it will return. I am writing a Python infrastructure that would run jobs and control them. For that I want to run jobs using the mosrun program as above, and save the process ID of the spawned process (29199 in this case). This naturally cannot be done using os.system or commands.getoutput, as the printed ID is not what the process prints to output... Any clues?

Edit:

Since the python script is only meant to initially run the script, the scripts need to run longer than the python shell. I guess it means the mosrun process cannot be the script's "son process". Any suggestions?

Thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about process