Linux: solve rare issue where VeraCrypt wrongly reports that another instance is already running. That happens when VeraCrypt doesn't close cleanly upon shutdown/reboot and on the next startup another process is running with the same PID as VeraCrypt before shutdow/reboot.

This commit is contained in:
Mounir IDRASSI 2015-02-08 17:54:08 +01:00
parent 2c96d17748
commit d1a3316e44

View file

@ -842,8 +842,9 @@ namespace VeraCrypt
wxLogLevel logLevel = wxLog::GetLogLevel();
wxLog::SetLogLevel (wxLOG_Error);
SingleInstanceChecker.reset (new wxSingleInstanceChecker (wxString (L".") + Application::GetName() + L"-lock-" + wxGetUserId()));
const wxString instanceCheckerName = wxString (L".") + Application::GetName() + L"-lock-" + wxGetUserId();
SingleInstanceChecker.reset (new wxSingleInstanceChecker (instanceCheckerName));
wxLog::SetLogLevel (logLevel);
@ -878,6 +879,7 @@ namespace VeraCrypt
if (write (showFifo, buf, 1) == 1)
{
close (showFifo);
Gui->ShowInfo (_("VeraCrypt is already running."));
Application::SetExitCode (0);
return false;
}
@ -890,12 +892,28 @@ namespace VeraCrypt
throw;
#endif
}
#endif
// This is a false positive as VeraCrypt is not running (pipe not available)
// we continue running after cleaning the lock file
// and creating a new instance of the checker
wxString lockFileName = wxGetHomeDir();
if ( lockFileName.Last() != wxT('/') )
{
lockFileName += wxT('/');
}
lockFileName << instanceCheckerName;
if (wxRemoveFile (lockFileName))
{
SingleInstanceChecker.reset (new wxSingleInstanceChecker (instanceCheckerName));
}
#else
wxLog::FlushActive();
Application::SetExitCode (1);
Gui->ShowInfo (_("VeraCrypt is already running."));
return false;
#endif
}
#ifdef TC_WINDOWS