title: How to terminate a process without os.kill() - OSGeo4W Python 2.5
body: <p>I'm using the distribution of Python2.5.2 included in the OSGeo4W installer.  This is a 32-bit distribution running on Windows 7.  Although PyQt is not installed by default by the OSGeo4W installer, we have installed it to the OSGeo4W Python installation and it has worked perfectly until now.  PyQt4 is version 4.8.6, and was built against a 32-bit version of Python.</p>
  
  <p>As part of a PyQt4-based UI, I currently spawn a QtCore.QProcess() and start it like this:</p>
  
  <pre><code>self.modelProcess = QtCore.QProcess()
  command = './OSGeo4W/gdal_python_exec.bat'
  argslist = 'QtCore.QString(uri, json.dumps(inputDict))
  self.modelProcess.start(command, argslist)
  </code></pre>
  
  <p>where <code>inputDict</code> is a Python dictionary mapping python strings to arbitrary values and <code>uri</code> is a string URI to the desired script to be run.</p>
  
  <p>While this process is running, the User is presented with a window containing several Qt widgets, including a 'cancel' button.  I have the following signal/slot configuration for the 'cancel' button:</p>
  
  <pre><code>self.cancelButton = QtGui.QPushButton('Cancel')
  self.cancelButton.clicked.connect(self.closeWindow)
  </code></pre>
  
  <p>And then elsewhere:</p>
  
  <pre><code>def closeWindow(self):
      self.modelProcess.kill()
  </code></pre>
  
  <p>According to the <a href="http://doc.qt.nokia.com/stable/qprocess.html#kill" rel="nofollow noreferrer">Qt documentation</a>,  this should kill the process (the <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qprocess.html#kill" rel="nofollow noreferrer">PyQt documentation</a> agrees on this point).  Unfortunately, this does not kill the QProcess.  If I have Windows Task Manager, I can see my CPU usage continue to escalate as the QProcess happily processes my program.</p>
  
  <p>I have read <a href="https://stackoverflow.com/questions/1064335/in-python-2-5-how-do-i-kill-a-subprocess">elsewhere on SO</a> that a subprocess can be killed in Python 2.5 by using <code>os.kill()</code>, but my distribution of Python does not include the <code>kill</code> function:</p>
  
  <pre><code>&gt;&gt;&gt; import os
  &gt;&gt;&gt; os.kill
  Traceback (most recent call last):
    File "(stdin)", line 1, in (module)
  AttributeError: 'module' object has no attribute 'kill'
  </code></pre>
  
  <p>Is there a different approach to killing a process in Python?  Some third-party module, perhaps?</p>
  
  <p>Many thanks.</p>