VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-02-08 17:54:08 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-02-08 17:57:00 +0100
commitd1a3316e4486433cb4d3f74016479998ac3ea62a (patch)
treee50de623bc163a0f5ab886fba9160cec2f4c971b /src/Main
parent2c96d17748eaff6fd77453b58476d965e54d59d7 (diff)
downloadVeraCrypt-d1a3316e4486433cb4d3f74016479998ac3ea62a.tar.gz
VeraCrypt-d1a3316e4486433cb4d3f74016479998ac3ea62a.zip
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.
Diffstat (limited to 'src/Main')
-rw-r--r--src/Main/GraphicUserInterface.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp
index 67d8d870..c29eef22 100644
--- a/src/Main/GraphicUserInterface.cpp
+++ b/src/Main/GraphicUserInterface.cpp
@@ -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