On Sun, Jul 25, 2010 at 9:02 PM, tazimk <tazimkol...@gmail.com> wrote: > Hi, > > I am using python's multiprocessing module to spawn new process > > as follows : > > 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
`multiprocessing` isn't the best module for this; use `subprocess` instead: from subprocess import Popen, PIPE process = Popen(["iostat"], stderr=open("a.txt", 'w'), stdout=PIPE) print("the PID is", process.pid) `multiprocessing` is used for parallelism in Python code, as an alternative to threads. `subprocess` is used for running external commands, as a preferred alternative to os.system() among other things. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list