Python subprocess problem!

python

(StepBack) #1

import subprocess
import time
from multiprocessing import Process
import os

def Run():

proc = subprocess.Popen(’ping www.google.com -c 2000’.split(), stdout=subprocess.PIPE)
output ,err = proc.communicate()
print proc.pid

if name == “main”:

p = Process(target=Run)
p.start()

print “Attack was started”
time.sleep(2)

p.terminate()

print “Attack was finished”

Hello guys i need your help.I want to say what i am doing.
This code will create process and this process generate 2000 icmp request packet in subprocess then i sleep 2 seconds my scripts then i terminante the process .Thiis my script’s goal.
But you see i create subprocess in Run function 2 seconds later i can terminate Run function but subprocess keep working still when reach 2000 icmp request.

How can i terminate subprocess when i terminate process

(sorry for bad english :frowning: )