Index: keepass2/KeePass/Util/GlobalMutexPool.cs =================================================================== --- keepass2.orig/KeePass/Util/GlobalMutexPool.cs 2013-05-17 23:38:10.295295000 -0500 +++ keepass2/KeePass/Util/GlobalMutexPool.cs 2013-05-17 23:39:15.020733923 -0500 @@ -83,13 +83,20 @@ byte[] pbEnc = File.ReadAllBytes(strPath); byte[] pb = ProtectedData.Unprotect(pbEnc, GmpOptEnt, DataProtectionScope.CurrentUser); - if(pb.Length == 8) + if(pb.Length == 12) { long lTime = BitConverter.ToInt64(pb, 0); DateTime dt = DateTime.FromBinary(lTime); - if((DateTime.UtcNow - dt).TotalSeconds < GmpMutexValidSecs) - return false; // Actively owned by other process + if((DateTime.UtcNow - dt).TotalSeconds < GmpMutexValidSecs) { + int pid = BitConverter.ToInt32(pb, 8); + try { + Process.GetProcessById(pid); // will throw if process is not running + return false; // Actively owned by other process + } catch (Exception) { } + } + // release the old mutex since process is not running + ReleaseMutexUnix (strName); } else { Debug.Assert(false); } } @@ -105,7 +112,9 @@ private static void WriteMutexFilePriv(string strPath) { - byte[] pb = BitConverter.GetBytes(DateTime.UtcNow.ToBinary()); + byte[] pb = new byte[12]; + BitConverter.GetBytes(DateTime.UtcNow.ToBinary()).CopyTo(pb, 0); + BitConverter.GetBytes(Process.GetCurrentProcess().Id).CopyTo(pb, 8); byte[] pbEnc = ProtectedData.Protect(pb, GmpOptEnt, DataProtectionScope.CurrentUser); File.WriteAllBytes(strPath, pbEnc);