windows code to detect if a process is still alive

Eli Zaretskii eliz at gnu.org
Thu Apr 14 06:35:12 UTC 2011


> From: Martin Pool <mbp at canonical.com>
> Date: Thu, 14 Apr 2011 15:49:30 +1000
> Cc: bazaar at lists.canonical.com
> 
> Basically this just fires when we try to take a lock and discover that
> it's held by someone else.  The lock info file records the username,
> hostname, processid and date taken.  If the hostname is the same as
> our local host, and the process is known not to be alive, it may be
> reasonable to assume the lock is now stale.  Having the pid be reused
> by someone else is fairly harmless.
> 
> It's a lot like the lock and backup-file recovery algorithm in vim and emacs.

Well, detection of lock owner in Emacs doesn't work on Windows,
because no one has written the code...

Anyway, the way to know if a process ID runs is to take a snapshot and
walk it.  There's also OpenProcess, but doing that requires certain
privileges, and I'm not sure you can assume that.

I have no idea how to get a snapshot of processes from Python.



More information about the bazaar mailing list