ProcLib 0.0.1.0
A cross-platform process runner.
Loading...
Searching...
No Matches
process.hxx
Go to the documentation of this file.
1//
2// Copyright (c) 2026 Jamie Kenyon. All Rights Reserved.
3//
4
5#pragma once
6
8
9#include <cstdint>
10#include <expected>
11
12#include <Windows.h>
13
14namespace pl
15{
18 {
19 Exited,
21 };
22
26 struct PlatformExitStatus
27 {
29 int32_t value = -1;
30 };
31
33 class PlatformProcess
34 {
35 public:
38
43 [[nodiscard]] auto start(std::filesystem::path const& executablePath, std::vector<std::string> const& arguments) -> std::error_code;
44
48 [[nodiscard]] auto terminate() -> std::error_code;
49
53 [[nodiscard]] auto kill(uint32_t const exitCode) -> std::error_code;
54
57 [[nodiscard]] auto wait() -> std::expected<PlatformExitStatus, std::error_code>;
58
59 private:
60 HANDLE _processHandle{};
61 };
62} // namespace pl
auto kill(uint32_t const exitCode) -> std::error_code
~PlatformProcess()
Destructor.
auto wait() -> std::expected< PlatformExitStatus, std::error_code >
auto terminate() -> std::error_code
auto start(std::filesystem::path const &executablePath, std::vector< std::string > const &arguments) -> std::error_code
Definition error.hxx:10
PlatformExitKind
The kind of raw exit status reported by the OS for a completed process.
Definition process.hxx:17
@ Exited
The process ran to completion, or was force-stopped with an OS-reported exit code.
@ Signaled
The process was stopped by a signal, with no OS-reported exit code.
PlatformExitKind kind
The kind of exit status reported by the OS.
Definition process.hxx:27
int32_t value
The exit code if kind == Exited; the signal number if kind == Signaled.
Definition process.hxx:28