Bitcoin Core 32.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 <optional>
13#include <string>
14
15namespace ipc {
16class Protocol;
17
24{
25public:
26 virtual ~Process() = default;
27
29 virtual std::tuple<mp::ProcessId, mp::SocketId> spawn(const std::string& new_exe_name, const fs::path& argv0_path) = 0;
30
32 virtual int waitSpawned(mp::ProcessId pid) = 0;
33
37 virtual std::optional<mp::SocketId> checkSpawned(int argc, char* argv[]) = 0;
38
40 virtual mp::SocketId connect(const fs::path& data_dir,
41 const std::string& dest_exe_name,
42 std::string& address) = 0;
43
45 virtual mp::SocketId bind(const fs::path& data_dir,
46 const std::string& exe_name,
47 std::string& address) = 0;
48};
49
52std::unique_ptr<Process> MakeProcess();
53} // namespace ipc
54
55#endif // BITCOIN_IPC_PROCESS_H
IPC process interface for spawning bitcoin processes and serving requests in processes that have been...
Definition: process.h:24
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 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.
virtual std::optional< mp::SocketId > checkSpawned(int argc, char *argv[])=0
Parse command line and determine if current process is a spawned child process.
Definition: ipc.h:17
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