9 #ifndef CPPCOMMON_SYSTEM_PROCESS_H
10 #define CPPCOMMON_SYSTEM_PROCESS_H
26 #define __PROCESS__ CppCommon::Process::CurrentProcessId()
48 uint64_t
pid()
const noexcept;
108 static
void Exit(
int result);
125 static
Process Execute(const std::
string& command, const std::vector<std::
string>* arguments =
nullptr, const std::map<std::
string, std::
string>* envars =
nullptr, const std::
string* directory =
nullptr,
Pipe* input =
nullptr,
Pipe* output =
nullptr,
Pipe* error =
nullptr);
134 Impl& impl() noexcept {
return reinterpret_cast<Impl&
>(_storage); }
135 const Impl& impl() const noexcept {
return reinterpret_cast<Impl const&
>(_storage); }
137 static const size_t StorageSize = 16;
138 #if defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__)
139 static const size_t StorageAlign = 4;
141 static const size_t StorageAlign = 8;
143 alignas(StorageAlign) std::byte _storage[StorageSize];
static Process ParentProcess()
Get the parent process.
static Process Execute(const std::string &command, const std::vector< std::string > *arguments=nullptr, const std::map< std::string, std::string > *envars=nullptr, const std::string *directory=nullptr, Pipe *input=nullptr, Pipe *output=nullptr, Pipe *error=nullptr)
Execute a new process.
static Process CurrentProcess()
Get the current process.
void Kill()
Kill the process.
static uint64_t ParentProcessId() noexcept
Get the parent process Id.
int WaitUntil(const UtcTimestamp ×tamp)
Wait the process to exit until the given timestamp.
int Wait()
Wait the process to exit.
bool IsRunning() const
Is the process is running?
static uint64_t CurrentProcessId() noexcept
Get the current process Id.
void swap(Process &process) noexcept
Swap two instances.
Process & operator=(const Process &process)
static void Exit(int result)
Exit the current process.
Process(const Process &process)
uint64_t pid() const noexcept
Get the process Id.
int WaitFor(const Timespan ×pan)
Wait the process to exit for the given timespan.
C++ Common project definitions.
Process inline implementation.