-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.hpp
More file actions
81 lines (68 loc) · 2.17 KB
/
Copy pathProcess.hpp
File metadata and controls
81 lines (68 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* @file Process.hpp
*
* Structured process execution for Vix Engine.
*/
#ifndef VIX_ENGINE_PROCESS_HPP
#define VIX_ENGINE_PROCESS_HPP
#include <filesystem>
#include <string>
#include <utility>
#include <vector>
namespace vix::engine::process
{
namespace fs = std::filesystem;
/**
* @brief Structured command to execute.
*
* argv[0] is the executable. Each argv entry is passed as one process
* argument and is never shell-split by the engine.
*/
struct Command
{
std::vector<std::string> argv; ///< Executable and arguments
fs::path workingDirectory; ///< Optional child working directory
/**
* @brief Environment overrides applied to the child process.
*
* Values replace existing variables with the same name. They do not mutate
* the parent process environment.
*/
std::vector<std::pair<std::string, std::string>> environment;
bool inheritEnvironment{true}; ///< Include the parent environment
bool mergeStdErr{true}; ///< Capture stderr in stdout order when true
/**
* @brief Check whether the command has an executable.
*/
bool valid() const;
};
/**
* @brief Structured process result.
*/
struct Result
{
bool started{false}; ///< true after the child process starts
int exitCode{0}; ///< Normalized process exit code
std::string displayCommand; ///< Human-readable command representation
std::string output; ///< Captured stdout and optionally stderr
std::string errorMessage; ///< Spawn or setup error, when available
bool producedOutput{false}; ///< true if output was captured
/**
* @brief Check whether the process started and exited successfully.
*/
bool success() const;
};
/**
* @brief Execute a structured command and capture output.
*/
Result execute(const Command &command);
/**
* @brief Normalize a platform raw exit status into a process exit code.
*/
[[nodiscard]] int normalize_exit_code(int raw) noexcept;
/**
* @brief Build a diagnostic-only display command.
*/
std::string display_command(const Command &command);
} // namespace vix::engine::process
#endif