Changeset View
Changeset View
Standalone View
Standalone View
src/bitcoind.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2018 The Bitcoin Core developers | // Copyright (c) 2009-2019 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#if defined(HAVE_CONFIG_H) | #if defined(HAVE_CONFIG_H) | ||||
#include <config/bitcoin-config.h> | #include <config/bitcoin-config.h> | ||||
#endif | #endif | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | static bool AppInit(int argc, char *argv[]) { | ||||
if (!gArgs.ParseParameters(argc, argv, error)) { | if (!gArgs.ParseParameters(argc, argv, error)) { | ||||
return InitError( | return InitError( | ||||
strprintf("Error parsing command line arguments: %s\n", error)); | strprintf("Error parsing command line arguments: %s\n", error)); | ||||
} | } | ||||
// Process help and version before taking care about datadir | // Process help and version before taking care about datadir | ||||
if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { | if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { | ||||
std::string strUsage = | std::string strUsage = | ||||
PACKAGE_NAME " Daemon version " + FormatFullVersion() + "\n"; | PACKAGE_NAME " version " + FormatFullVersion() + "\n"; | ||||
if (gArgs.IsArgSet("-version")) { | if (gArgs.IsArgSet("-version")) { | ||||
strUsage += FormatParagraph(LicenseInfo()); | strUsage += FormatParagraph(LicenseInfo()); | ||||
} else { | } else { | ||||
strUsage += "\nUsage: bitcoind [options] " | strUsage += "\nUsage: bitcoind [options] " | ||||
"Start " PACKAGE_NAME " Daemon\n"; | "Start " PACKAGE_NAME "\n"; | ||||
strUsage += "\n" + gArgs.GetHelpMessage(); | strUsage += "\n" + gArgs.GetHelpMessage(); | ||||
} | } | ||||
tfm::format(std::cout, "%s", strUsage); | tfm::format(std::cout, "%s", strUsage); | ||||
return true; | return true; | ||||
} | } | ||||
try { | try { | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | try { | ||||
return false; | return false; | ||||
} | } | ||||
if (gArgs.GetBoolArg("-daemon", false)) { | if (gArgs.GetBoolArg("-daemon", false)) { | ||||
#if HAVE_DECL_DAEMON | #if HAVE_DECL_DAEMON | ||||
#if defined(MAC_OSX) | #if defined(MAC_OSX) | ||||
#pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||||
#endif | #endif | ||||
tfm::format(std::cout, PACKAGE_NAME " daemon starting\n"); | tfm::format(std::cout, PACKAGE_NAME " starting\n"); | ||||
// Daemonize | // Daemonize | ||||
if (daemon(1, 0)) { | if (daemon(1, 0)) { | ||||
// don't chdir (1), do close FDs (0) | // don't chdir (1), do close FDs (0) | ||||
return InitError( | return InitError( | ||||
strprintf("daemon() failed: %s\n", strerror(errno))); | strprintf("daemon() failed: %s\n", strerror(errno))); | ||||
} | } | ||||
#if defined(MAC_OSX) | #if defined(MAC_OSX) | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |