X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fos_process.hpp;h=e1b1df17179e8457239e9b021d593b30d23eaac5;hb=283551aa08de851453ec8ac378efdbd920a26364;hp=f1dd5172b6cf777b40c5363c4270f71ae11fddd5;hpb=48412ffde3dd4710c96d5e8d9cfdf1789e4d703a;p=apitrace diff --git a/common/os_process.hpp b/common/os_process.hpp index f1dd517..e1b1df1 100644 --- a/common/os_process.hpp +++ b/common/os_process.hpp @@ -31,12 +31,58 @@ #define _OS_PROCESS_HPP_ +#ifdef _WIN32 +#include +#else +#include +#include +#endif + #include "os.hpp" namespace os { +typedef +#ifdef _WIN32 + DWORD +#else + pid_t +#endif +ProcessId; + + +static inline ProcessId +getCurrentProcessId(void) { +#ifdef _WIN32 + return GetCurrentProcessId(); +#else + return getpid(); +#endif +} + + +static inline void +setEnvironment(const char *name, const char *value) { +#ifdef _WIN32 + SetEnvironmentVariableA(name, value); +#else + setenv(name, value, 1); +#endif +} + + +static inline void +unsetEnvironment(const char *name) { +#ifdef _WIN32 + SetEnvironmentVariableA(name, NULL); +#else + unsetenv(name); +#endif +} + + int execute(char * const * args);