title: Killing sub process that run inside a thread
body: <p>I'm using python 3.5.3 with PyQT 5 and I have written GUI with it.
  This GUI run python code python code with subprocess.run.</p>
  
  <p>In order to leave my GUI active and not frozen during the subprocess operation , i'm running the subprocess in a thread.</p>
  
  <p>In the GUI i have stop button that if the user pressed  , I want to terminate the subprocess.</p>
  
  <p>I have no problem to kill the thread by using terminate method of the thread.
  But that's don't terminate the subprocess.</p>
  
  <p>I've tried to use Popen instead of run but I cant make it to run as subprocess.run does.
  in addition , I prefer to use the recommended way by Python that's give me also the check_error option</p>
  
  <p>This is how I use subprocess:</p>
  
  <pre><code>class c_run_test_thread(QtCore.QThread):
  
      def __init__(self,test_file,log_file):
          QtCore.QThread.__init__(self)
          self.test_file = test_file
          self.log_file = log_file
  
      def __del__(self):
          self.wait()
  
      def run(self):
          # Thread logic
  
          try:
              # Run the test with all prints and exceptions go to global log file
              self.test_sub_process = subprocess.run(["python", self.test_file],stdout = self.log_file, stderr = self.log_file,check = True)
  
      except subprocess.CalledProcessError as error:
          print("Error : {}".format(error))
  
      # Flush memory to file
      self.log_file.flush(
  
  def stop(self):
  
      # Flush memory to file
      self.log_file.flush()
  </code></pre>
  
  <p>And I terminate the thread by </p>
  
  <pre><code># Stop test thread
  self.thread_run_test.terminate()
  </code></pre>
  
  <p>To sum things up , I want to kill thread while killing its sub process too.</p>