Sane C++ Libraries
C++ Platform Abstraction Libraries
ProcessDescriptor.h
1// Copyright (c) Stefano Cristiano
2// SPDX-License-Identifier: MIT
3#pragma once
4
5#include "../Foundation/Result.h"
6#include "../Foundation/UniqueHandle.h"
7
8namespace SC
9{
10struct SC_COMPILER_EXPORT ProcessDescriptor;
11namespace detail
12{
13#if SC_PLATFORM_WINDOWS
14
15struct SC_COMPILER_EXPORT ProcessDescriptorDefinition
16{
17 using Handle = void*; // HANDLE
18#ifdef __clang__
19 static constexpr void* Invalid = __builtin_constant_p(-1) ? (void*)-1 : (void*)-1; // INVALID_HANDLE_VALUE
20#else
21 static constexpr void* Invalid = (void*)-1; // INVALID_HANDLE_VALUE
22#endif
23 static Result releaseHandle(Handle& handle);
24};
25
26#else
27
28struct SC_COMPILER_EXPORT ProcessDescriptorDefinition
29{
30 using Handle = int; // pid_t
31 static Result releaseHandle(Handle& handle);
32
33 static constexpr Handle Invalid = 0; // invalid pid_t
34};
35
36#endif
37} // namespace detail
38} // namespace SC
39
41struct SC::ProcessDescriptor : public UniqueHandle<detail::ProcessDescriptorDefinition>
42{
44 {
45 int32_t status = -1;
46 };
47};
#define SC_COMPILER_EXPORT
Macro for symbol visibility in non-MSVC compilers.
Definition: Compiler.h:78
int int32_t
Platform independent (4) bytes signed int.
Definition: PrimitiveTypes.h:46
Definition: ProcessDescriptor.h:44
Wraps an OS Process descriptor.
Definition: ProcessDescriptor.h:42
Move only handle that has a special tag value flagging its invalid state.
Definition: UniqueHandle.h:67