|
|
|
@ -187,7 +187,11 @@ void Shutdown()
@@ -187,7 +187,11 @@ void Shutdown()
|
|
|
|
|
pwalletMain->Flush(true); |
|
|
|
|
#endif |
|
|
|
|
#ifndef WIN32 |
|
|
|
|
boost::filesystem::remove(GetPidFile()); |
|
|
|
|
try { |
|
|
|
|
boost::filesystem::remove(GetPidFile()); |
|
|
|
|
} catch (const boost::filesystem::filesystem_error& e) { |
|
|
|
|
LogPrintf("%s: Unable to remove pidfile: %s\n", __func__, e.what()); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
UnregisterAllValidationInterfaces(); |
|
|
|
|
#ifdef ENABLE_WALLET |
|
|
|
@ -862,9 +866,15 @@ bool AppInit2(boost::thread_group& threadGroup)
@@ -862,9 +866,15 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|
|
|
|
boost::filesystem::path pathLockFile = GetDataDir() / ".lock"; |
|
|
|
|
FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
|
|
|
|
|
if (file) fclose(file); |
|
|
|
|
static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); |
|
|
|
|
if (!lock.try_lock()) |
|
|
|
|
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin Core is probably already running."), strDataDir)); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); |
|
|
|
|
if (!lock.try_lock()) |
|
|
|
|
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin Core is probably already running."), strDataDir)); |
|
|
|
|
} catch(const boost::interprocess::interprocess_exception& e) { |
|
|
|
|
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin Core is probably already running.") + " %s.", strDataDir, e.what())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#ifndef WIN32 |
|
|
|
|
CreatePidFile(GetPidFile(), getpid()); |
|
|
|
|
#endif |
|
|
|
|