diff -r 3bdd3bf17cfa -r 6328445b0e71 mercurial/util.py --- a/mercurial/util.py Thu Mar 30 18:43:46 2006 +0200 +++ b/mercurial/util.py Thu Mar 30 18:20:08 2006 -0800 @@ -535,9 +535,10 @@ pf = pf[1:-1] # Remove the quotes return pf - try: # ActivePython can create hard links using win32file module - import win32api, win32con, win32file + try: # Mark Hammond's win32all package allows better functionality on Windows + import win32api, win32con, win32file, pywintypes + # create hard links using win32file module def os_link(src, dst): # NB will only succeed on NTFS win32file.CreateHardLink(dst, src) @@ -554,12 +555,19 @@ return os.stat(pathname).st_nlink def testpid(pid): - '''return False if pid is dead, True if running or not known''' + '''return True if pid is still running or unable to determine, False otherwise''' try: - win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, - False, pid) - except: - return True + handle = win32api.OpenProcess(win32con.PROCESS_QUERY_INFORMATION, False, pid) + if handle: + status = win32process.GetExitCodeProcess(handle) + if status == win32con.STILL_ACTIVE: + return True + else: + return False + except pywintypes.error, details: + if details[0] == 87: # ERROR_INVALID_PARAMETER + return False + return True except ImportError: def testpid(pid):