Python Subprocess CREATE_NEW_CONSOLE Windows Not Closing on kill()
<p>On a Windows server I start subprocs from the main script with a new console window and add it into a list of procs so I can close them:</p>

<pre><code>p = Popen(["python", 'secondscript.py', arg1, arg2, arg3], creationflags=CREATE_NEW_CONSOLE)
Proc.append(p)
</code></pre>

<p>Later on if I kill the procs with:</p>

<pre><code>for p in Proc:
    p.kill()
</code></pre>

<p>They do seem to stop running but I do get left with console windows remaining open. In itself not a huge deal but that can add up over time and start causing issues.</p>

<p>Life is a lot easier using the new console flag but is there a neater way of making sure the console windows close properly? I could rely on a taskkill from the OS lib maybe but that doesn't seem like a good way of doing it.</p>

<p>I had a look around it looks like some people had problems on Linux servers and had to send a sigkill but I thought this was what the kill() was supposed to do anyway.</p>

<p>I might have to just use kill() to stop it working then a taskkil to tidy up but I'd appreciate any advice if there is a neater way of doing that.</p>