I would like to create a subprocess of a process.
What would be a working example which shows how to accomplish this?
Launching and monitoring a subprocess:
import subprocess, time, os, signal
args=['/usr/bin/vmstat','-n','2']
app=subprocess.Popen(args=args, stdout=open('somefile','w'))
print "Your app's PID is %s. You can now process data..." % app.pid
time.sleep(5)
if app.poll() == None: print "Process is still running after 5s."
print "The app outputed %s bytes." % len(open('somefile','r').read())
print "Stopping the process..."
os.kill(app.pid, signal.SIGTERM)
There is more to it. Just check the Popen docs.