|
Motion Master 6.0.0-alpha.86
Next-generation motion control software
|
Classes | |
| struct | Child |
| A started child, as the platform identifies it. More... | |
Functions | |
| 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. | |
| bool | childAlive (const Child &child) |
Whether child is still running. | |
| bool | terminateChild (const Child &child, std::chrono::milliseconds grace) |
Asks child to exit, waits up to grace, then kills it and everything it started. | |
| bool mm::auto_tuning::detail::childAlive | ( | const Child & | child | ) |
Whether child is still running.
This reaps a child that exited, which is how the exit is detected at all, and it is why only Process::start calls it: a reaped process id may be reissued to an unrelated process, so the caller must forget the child as soon as this returns false.
| std::expected< Child, std::string > mm::auto_tuning::detail::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.
The child inherits this process's stdout and stderr when logFile is empty. It never inherits stdin: the auto-tuning program reads none, and a child sharing a terminal's stdin can stop the whole process group.
binary is reported here, by the platform, rather than pre-checked — a check followed by a spawn would still have to handle the spawn failing. | bool mm::auto_tuning::detail::terminateChild | ( | const Child & | child, |
| std::chrono::milliseconds | grace | ||
| ) |
Asks child to exit, waits up to grace, then kills it and everything it started.
Returns once the child is gone. The auto-tuning program handles a termination signal and shuts its server down; the kill is for a child wedged inside a numerical routine, and it takes the whole group so that nothing is left holding the port.
false when the signal was enough, true when the kill was needed. The caller logs the difference: a child that ignores a termination signal is worth knowing about, and it is the case where a leftover process could hold the port against the next start.