title: Problems killing a process with Python on Solaris
body: <p>I have a C++ program, called <strong>C</strong>, that is designed to shut down when it receives a SIGINT signal. I've written a Python program <strong>P</strong> that runs <strong>C</strong> as a subprocess.  I want <strong>P</strong> to stop <strong>C</strong>.  I tried 3 things and I'd like to know why some of them didn't work.</p>
  
  <p>Attempt #1:</p>
  
  <pre><code>import subprocess
  import signal
  import os
  
  p = subprocess.Popen(...)
  ...
  os.killpg(p.pid, signal.SIGINT)
  </code></pre>
  
  <p>This code gives me the error</p>
  
  <blockquote>
    <p>OSError [Errno 3]: No such process` </p>
  </blockquote>
  
  <p>even though the <code>p.pid</code> matches the <code>pid</code> displayed by <a href="http://en.wikipedia.org/wiki/Ps_%28Unix%29" rel="nofollow">ps</a>.</p>
  
  <p>Attempt #2:</p>
  
  <pre><code>import subprocess
  import signal
  import os
  
  p = subprocess.Popen(...)
  ...
  os.system('kill -SIGINT %u' % p.pid)
  </code></pre>
  
  <p>This gives me the error</p>
  
  <blockquote>
    <p>sh: kill: bad signal` </p>
  </blockquote>
  
  <p>even though <code>kill -SIGINT &lt;pid&gt;</code> works from the terminal.</p>
  
  <p>Attempt #3:</p>
  
  <pre><code>import subprocess
  import signal
  import os
  
  p = subprocess.Popen(...)
  ...
  os.system('kill -2 %u' % p.pid)
  </code></pre>
  
  <p>This works.</p>
  
  <p>My question is, why didn't #1 and #2 work?</p>
  
  <hr>
  
  <p>Edit: my original assumption was that since the documentation for <code>os.kill()</code> says <code>New in version 2.7: Windows support</code>, I thought that <code>os.kill()</code> is (a) first available in 2.7 and (b) works in Windows. After reading the answers below, I ran <code>os.kill()</code> on Solaris, which I should have done in the first place sorry, and it does work in 2.4.  Obviously, the documentation means that Windows support is new in 2.7.  Opps.</p>