Coverage Report

Created: 2026-10-07 13:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/tmp/bitcoin/src/ipc/process.h
Line
Count
Source
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
15
namespace ipc {
16
class Protocol;
17
18
//! IPC process interface for spawning bitcoin processes and serving requests
19
//! in processes that have been spawned.
20
//!
21
//! There will be different implementations of this interface depending on the
22
//! platform (e.g. unix, windows).
23
class Process
24
{
25
public:
26
48
    virtual ~Process() = default;
27
28
    //! Spawn process and return socket id for communicating with it.
29
    virtual std::tuple<mp::ProcessId, mp::SocketId> spawn(const std::string& new_exe_name, const fs::path& argv0_path) = 0;
30
31
    //! Wait for spawned process to exit and return its exit code.
32
    virtual int waitSpawned(mp::ProcessId pid) = 0;
33
34
    //! Parse command line and determine if current process is a spawned child
35
    //! process. If so, return a socket id for communicating with the parent
36
    //! process, otherwise return std::nullopt.
37
    virtual std::optional<mp::SocketId> checkSpawned(int argc, char* argv[]) = 0;
38
39
    //! Canonicalize and connect to address, returning socket id.
40
    virtual mp::SocketId connect(const fs::path& data_dir,
41
                        const std::string& dest_exe_name,
42
                        std::string& address) = 0;
43
44
    //! Create listening socket, bind and canonicalize address, and return socket id.
45
    virtual mp::SocketId bind(const fs::path& data_dir,
46
                     const std::string& exe_name,
47
                     std::string& address) = 0;
48
};
49
50
//! Constructor for Process interface. Implementation will vary depending on
51
//! the platform (unix or windows).
52
std::unique_ptr<Process> MakeProcess();
53
} // namespace ipc
54
55
#endif // BITCOIN_IPC_PROCESS_H