32 : m_exe_name(exe_name), m_process_argv0(process_argv0), m_init(
init),
36 std::unique_ptr<interfaces::Init> spawnProcess(
const char* new_exe_name)
override
39 int fd = m_process->spawn(new_exe_name, m_process_argv0, pid);
41 auto init = m_protocol->connect(fd, m_exe_name);
42 Ipc::addCleanup(*
init, [
this, new_exe_name, pid] {
43 int status = m_process->waitSpawned(pid);
44 LogPrint(::
BCLog::IPC,
"Process %s pid %i exited with status %i\n", new_exe_name, pid, status);
48 bool startSpawnedProcess(
int argc,
char* argv[],
int&
exit_status)
override
52 if (!m_process->checkSpawned(argc, argv, fd)) {
55 m_protocol->serve(fd, m_exe_name, m_init);
59 void addCleanup(std::type_index type,
void* iface, std::function<
void()> cleanup)
override
61 m_protocol->addCleanup(type, iface, std::move(cleanup));
63 Context& context()
override {
return m_protocol->context(); }
64 const char* m_exe_name;
65 const char* m_process_argv0;
67 std::unique_ptr<Protocol> m_protocol;
68 std::unique_ptr<Process> m_process;
74 std::unique_ptr<Ipc>
MakeIpc(
const char* exe_name,
const char* process_argv0,
Init&
init)
76 return std::make_unique<ipc::IpcImpl>(exe_name, process_argv0,
init);
std::unique_ptr< interfaces::Init > init
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.
#define LogPrint(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()
std::unique_ptr< Process > MakeProcess()
Constructor for Process interface.