Bitcoin Core 31.99.0
P2P Digital Currency
process.h
Go to the documentation of this file.
1// Copyright (c) 2021-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_IPC_PROCESS_H
6#define BITCOIN_IPC_PROCESS_H
7
8#include <util/fs.h>
9
10#include <memory>
11#include <ipc/util.h>
12#include <string>
13
14namespace ipc {
15class Protocol;
16
23{
24public:
25 virtual ~Process() = default;
26
28 virtual std::tuple<mp::ProcessId, mp::SocketId> spawn(const std::string& new_exe_name, const fs::path& argv0_path) = 0;
29
31 virtual int waitSpawned(mp::ProcessId pid) = 0;
32
36 virtual bool checkSpawned(int argc, char* argv[], mp::SocketId& socket) = 0;
37
39 virtual mp::SocketId connect(const fs::path& data_dir,
40 const std::string& dest_exe_name,
41 std::string& address) = 0;
42
44 virtual mp::SocketId bind(const fs::path& data_dir,
45 const std::string& exe_name,
46 std::string& address) = 0;
47};
48
51std::unique_ptr<Process> MakeProcess();
52} // namespace ipc
53
54#endif // BITCOIN_IPC_PROCESS_H
IPC process interface for spawning bitcoin processes and serving requests in processes that have been...
Definition: process.h:23
virtual mp::SocketId connect(const fs::path &data_dir, const std::string &dest_exe_name, std::string &address)=0
Canonicalize and connect to address, returning socket id.
virtual ~Process()=default
virtual bool checkSpawned(int argc, char *argv[], mp::SocketId &socket)=0
Parse command line and determine if current process is a spawned child process.
virtual mp::SocketId bind(const fs::path &data_dir, const std::string &exe_name, std::string &address)=0
Create listening socket, bind and canonicalize address, and return socket id.
virtual int waitSpawned(mp::ProcessId pid)=0
Wait for spawned process to exit and return its exit code.
virtual std::tuple< mp::ProcessId, mp::SocketId > spawn(const std::string &new_exe_name, const fs::path &argv0_path)=0
Spawn process and return socket id for communicating with it.
Definition: ipc.h:13
std::unique_ptr< Process > MakeProcess()
Constructor for Process interface.
Definition: process.cpp:157
int ProcessId
Definition: util.h:26
int SocketId
Definition: util.h:27