Motion Master 6.0.0-alpha.111
Next-generation motion control software
Loading...
Searching...
No Matches
child_process.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <expected>
6#include <filesystem>
7#include <optional>
8#include <string>
9#include <vector>
10
29
30namespace mm::core {
31
33struct Child {
34 std::int64_t pid = 0;
35 std::intptr_t handle = 0;
36 std::intptr_t group = 0;
37};
38
48std::expected<Child, std::string> spawnChild(const std::filesystem::path& binary,
49 const std::vector<std::string>& args,
50 const std::filesystem::path& logFile);
51
57bool childAlive(const Child& child);
58
68bool terminateChild(const Child& child, std::chrono::milliseconds grace);
69
77std::optional<int> waitChild(const Child& child, std::chrono::milliseconds timeout);
78
79} // namespace mm::core
Definition http_server.h:27
std::expected< Child, std::string > spawnChild(const std::filesystem::path &binary, const std::vector< std::string > &args, const std::filesystem::path &logFile)
Runs binary with args, with its output appended to logFile.
Definition child_process_posix.cc:42
bool terminateChild(const Child &child, std::chrono::milliseconds grace)
Asks child to exit, waits up to grace, then kills it and everything it started.
Definition child_process_posix.cc:142
std::optional< int > waitChild(const Child &child, std::chrono::milliseconds timeout)
Waits up to timeout for child to exit, and reaps it.
Definition child_process_posix.cc:115
bool childAlive(const Child &child)
Whether child is still running.
Definition child_process_posix.cc:108
std::chrono::milliseconds timeout
Definition somanet_procedures.cc:464
A started child, as the platform identifies it.
Definition child_process.h:33
std::int64_t pid
Definition child_process.h:34
std::intptr_t group
Definition child_process.h:36
std::intptr_t handle
Definition child_process.h:35