Search code examples
enthoughtcanopy

How to test if Canopy editor is open


Is there a way to test if the Canopy editor is open/running that would work across platforms?

On Mac/Unix, it seems to work to check for canopy.app.main in the output of "ps aux", but that is not possible on most Windows. I found a tasklist command that is similar, but it appears Canopy runs as a generic pythonw program.


Solution

  • At present, on all OSes, if Canopy is running, then there will be a text file process.lck in the configuration/preferences directory. The second line of the file is the process ID. If Canopy was forced-stopped, the file will still be present even though Canopy is not running, so you should check that this process ID is still running. These implementation details could change in a future version.