Question

I have a path where I have many executables (around 800). I need to know if some of those executables are running. This is because I need to run a build and if the executables are running I cannot recreate them (access error when linker is invoked).

What I do currently is to run taskkill (I am on Windows platform) on all those executables. This takes time and I'd like to know if there's a faster/better way.

The build scripts are written in python but other solutions are welcome if we can easily integrate them.

Iulian

Was it helpful?

Solution

For similar purposes I have used psutil library. Some hints:

  • list processes with psutil.pids() (reference)
  • inspect process information with process = psutil.Process(pid) (reference)
  • do process.kill or process.terminate()

Installation on windows - pip will do installation from the source (which means compiling), so you probably want to download binary installation from https://pypi.python.org/pypi/psutil/#downloads.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top