[BangPypers] Popen.terminate() - WindowsError: [Error 5] Access is denied

Vishal vsapre80 at gmail.com
Tue Mar 6 10:24:08 CET 2012


Hi,

Take a good look at all the arguments that Popen() provides, there might be
some help there.

To my best knowlege:

In general, on Winodws, if Popen() is used to create a process, and this
process creates its child nodes independently, it is not possible to kill
the children, using the process handle provided by Popen().

Windows will not allow you to kill processes that you have not started,
unless you can prove that you have administrative privilege...which means
you will have to use some windows native api :(.
So, You might be able to kill them by recording their pid's somehow, then
using WMI or PyWin32 to kill them.

Cheers,
Vishal

On Tue, Feb 28, 2012 at 11:49 PM, Nikunj Badjatya
<nikunjbadjatya at gmail.com>wrote:

> Any clues guys?
>
>
>
>
> On Tue, Feb 28, 2012 at 12:48 PM, <Nikunj.Badjatya at emc.com> wrote:
>
> > Howdy,
> >
> > Py ver - 3.2, Windows-XP . Logged in as user with admin privileges.
> > >From my main python program, I am running powershell program using
> > subprocess.Popen(....).
> > Now I have created a signal_handler() function in main python script
> which
> > will handle CTRL-C ( This works fine ).
> > Now when I put "proc.terminate()" in my signal_handler() function to
> > terminate the subprocess created as well,
> > It is giving me "WindowsError: [Error 5] Access is denied" error.
> > I have tried with os.kill() also, same error.  Tried with Popen.kill()
> > also same error. Have googled a bit but couldn't understand them.
> >
> > In general,  How to kill a subprocesses created from a python program.?
> If
> > that subprocess also creates a new process from itself, how can I kill
> all
> > child processes from my main python script.?
> >
> > Any ideas.??
> >
> >
> > Thanks,
> > Nikunj
> >
> > 7  Switch off as you go  | qRecycle always  | P  Save Paper - Save Trees
> |
> > Go Green
> >
> > _______________________________________________
> > BangPypers mailing list
> > BangPypers at python.org
> > http://mail.python.org/mailman/listinfo/bangpypers
> >
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>



-- 
Thanks and best regards,
Vishal Sapre

---
"Life is 10% how you make it, and 90% how you take it"
"बहुजन हिताय, बहुजन सुखाय (Benefit for most people, Happiness for most
people.)"
---
Please DONT print this email, unless you really need to.
Save Energy & Paper. Save the Earth.


More information about the BangPypers mailing list