65 std::unique_ptr<interfaces::Init> spawnProcess(
const char*
new_exe_name)
override
69 auto init = m_protocol->connect(m_protocol->makeStream(
socket));
71 int status = m_process->waitSpawned(
pid);
79 std::optional<mp::SocketId>
socket{m_process->checkSpawned(
argc,
argv)};
84 m_protocol->serve(m_init, [&] {
return m_protocol->makeStream(*
socket); } );
88 std::unique_ptr<interfaces::Init> connectAddress(std::string& address)
override
90 if (address.empty() || address ==
"0")
return nullptr;
92 if (address ==
"auto") {
100 }
catch (
const std::system_error&
e) {
102 if (
e.code() == std::errc::connection_refused ||
e.code() == std::errc::no_such_file_or_directory ||
e.code() == std::errc::not_a_directory) {
106 }
catch (
const std::invalid_argument&) {
113 return m_protocol->connect(m_protocol->makeStream(fd));
120 void disconnectIncoming()
override
122 m_protocol->disconnectIncoming();
124 void addCleanup(std::type_index type,
void*
iface, std::function<
void()> cleanup)
override
126 m_protocol->addCleanup(type,
iface, std::move(cleanup));
128 Context&
context()
override {
return m_protocol->context(); }
130 const char* m_process_argv0;
132 std::unique_ptr<Protocol> m_protocol;
133 std::unique_ptr<Process> m_process;
fs::path GetDataDirNet() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Get data directory path with appended network identifier.
Initial interface created when a process is first started, and used to give and get access to other i...
Interface providing access to interprocess-communication (IPC) functionality.
is a home for public enum and struct type definitions that are used internally by ipc code,...
#define LogDebug(category,...)
std::unique_ptr< Ipc > MakeIpc(const char *exe_name, const char *process_argv0, Init &init)
Return implementation of Ipc interface.
std::unique_ptr< Protocol > MakeCapnpProtocol(const char *exe_name)
std::unique_ptr< Process > MakeProcess()
Constructor for Process interface.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.