Skip to content Skip to sidebar Skip to footer

Cross-platform Way To Terminate A Process In Python

When I try to kill a process in windows with the subprocess.Popen.terminate() or kill() commands, I get an access denied error. I really need a cross-platform way to terminate the

Solution 1:

You can easily make a platform independent call by doing something trivial like:

try:
    import win32
    defkill(param):
        # the code from S.Lotts linkexcept ImportError:
    defkill(param):
        # the unix way

Why this doesn't exist in python by default I don't know, but there are very similar problems in other areas like file change notifications where it really isn't that hard to make a platform independent lib (or at least win+mac+linux). I guess it's open source so you have to fix it yourself :P

Post a Comment for "Cross-platform Way To Terminate A Process In Python"