windows code to detect if a process is still alive

Alexander Belchenko bialix at ukr.net
Thu Apr 14 09:34:14 UTC 2011


Eli Zaretskii пишет:
>> 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.

http://gallery.technet.microsoft.com/scriptcenter/6fef07a6-c68c-4609-b2a4-bff5dcd23c8e



More information about the bazaar mailing list