![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
A program run in the background, its output collected as it arrives. More...
#include <child_process.h>
Public Member Functions | |
| bool | start (const std::filesystem::path &program, const std::vector< std::string > &args, const std::filesystem::path &workingDir={}) |
Start program with args in workingDir, ending any program started before. | |
| void | stop () |
| End the program and everything it started, and wait for it. | |
| std::string | takeOutput () |
| Take the output that arrived since the last call. | |
| bool | running () |
| Whether a program was started and has not yet exited. | |
| int | exitCode () |
| How the last program exited. | |
A program run in the background, its output collected as it arrives.
Standard output and error share one pipe, read on a thread of the process's own, so a caller polls output() and finished() from its frame. stop() ends the program and everything it started - a build's compilers included - so nothing outlives it. Should this process die without stopping it, the program is ended too: on Windows with all it started, its job's; on Linux it alone is sent SIGTERM, and what it started is its own to end. Linux sends it when the thread that started the program ends, so start one from a thread that lives as long as it should.
| bool Vkm::Engine::ChildProcess::start | ( | const std::filesystem::path & | program, |
| const std::vector< std::string > & | args, | ||
| const std::filesystem::path & | workingDir = {} ) |
Start program with args in workingDir, ending any program started before.
| program | The executable, by path. |
| args | Its arguments, each passed as one argument. |
| workingDir | Where it runs; empty keeps this process's. |
| std::string Vkm::Engine::ChildProcess::takeOutput | ( | ) |
Take the output that arrived since the last call.
| bool Vkm::Engine::ChildProcess::running | ( | ) |
Whether a program was started and has not yet exited.
| int Vkm::Engine::ChildProcess::exitCode | ( | ) |
How the last program exited.