diff --git a/src/ipc/interfaces.cpp b/src/ipc/interfaces.cpp index 71f1f4ee499..73a616bfb95 100644 --- a/src/ipc/interfaces.cpp +++ b/src/ipc/interfaces.cpp @@ -62,7 +62,7 @@ public: } std::unique_ptr spawnProcess(const char* new_exe_name) override { - int pid; + mp::ProcessId pid; int fd = m_process->spawn(new_exe_name, m_process_argv0, pid); LogDebug(::BCLog::IPC, "Process %s pid %i launched\n", new_exe_name, pid); auto init = m_protocol->connect(fd); diff --git a/src/ipc/process.cpp b/src/ipc/process.cpp index dcde50e220a..ec658a9af26 100644 --- a/src/ipc/process.cpp +++ b/src/ipc/process.cpp @@ -32,7 +32,7 @@ namespace { class ProcessImpl : public Process { public: - int spawn(const std::string& new_exe_name, const fs::path& argv0_path, int& pid) override + int spawn(const std::string& new_exe_name, const fs::path& argv0_path, mp::ProcessId& pid) override { return mp::SpawnProcess(pid, [&](int fd) { fs::path path = argv0_path; @@ -41,7 +41,7 @@ public: return std::vector{fs::PathToString(path), "-ipcfd", strprintf("%i", fd)}; }); } - int waitSpawned(int pid) override { return mp::WaitProcess(pid); } + int waitSpawned(mp::ProcessId pid) override { return mp::WaitProcess(pid); } bool checkSpawned(int argc, char* argv[], int& fd) override { // If this process was not started with a single -ipcfd argument, it is diff --git a/src/ipc/process.h b/src/ipc/process.h index 67c69593abd..13a004d7ca3 100644 --- a/src/ipc/process.h +++ b/src/ipc/process.h @@ -8,6 +8,7 @@ #include #include +#include #include namespace ipc { @@ -25,10 +26,10 @@ public: //! Spawn process and return socket file descriptor for communicating with //! it. - virtual int spawn(const std::string& new_exe_name, const fs::path& argv0_path, int& pid) = 0; + virtual int spawn(const std::string& new_exe_name, const fs::path& argv0_path, mp::ProcessId& pid) = 0; //! Wait for spawned process to exit and return its exit code. - virtual int waitSpawned(int pid) = 0; + virtual int waitSpawned(mp::ProcessId pid) = 0; //! Parse command line and determine if current process is a spawned child //! process. If so, return true and a file descriptor for communicating diff --git a/src/ipc/util.h b/src/ipc/util.h new file mode 100644 index 00000000000..58912a8575d --- /dev/null +++ b/src/ipc/util.h @@ -0,0 +1,21 @@ +// Copyright (c) The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_IPC_UTIL_H +#define BITCOIN_IPC_UTIL_H + +#include +#include +#include + +namespace mp { +// Definitions that can be deleted when libmultiprocess subtree is updated to +// v14. Having these allows Bitcoin Core changes to be decoupled from +// libmultiprocess changes so they don't have to be reviewed in a single PR. +#if MP_MAJOR_VERSION < 14 +using ProcessId = int; +#endif +} // namespace mp + +#endif // BITCOIN_IPC_UTIL_H