obtaining pid of child process

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tazimk
    New Member
    • Jul 2010
    • 1

    obtaining pid of child process

    Hi,

    I am using python's multiprocessing module to spawn new process

    as follows :
    Code:
    import multiprocessing
    import os
    d = multiprocessing.Process(target=os.system,args=('iostat 2 > a.txt',))
    d.start()
    I want to obtain pid of iostat command or the command executed using multiprocessing module

    When I execute :

    d.pid

    it gives me pid of subshell in which this command is running .

    Any help will be valuable .

    Thanks in advance
    Last edited by bvdet; Jul 26 '10, 01:06 PM. Reason: Add code tags
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    You would likely have to use the OS for that. See if top/htop returns the desired pid. You can pipe the output to a file and read it from a program.

    Comment

    Working...