Branch
Hash :
605c2bf4
Author :
Thomas de Grivel
Date :
2024-11-27T15:02:23
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
/*
MIT License
Copyright (c) 2019 win32ports
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#ifndef SYS_WAIT_H
#define SYS_WAIT_H
#ifdef WIN32
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifdef __GNUC__
#include <sys/time.h> /* for timeval */
#endif /* __GNUC__ */
#include <errno.h>
#include <string.h>
#ifndef _INC_WINDOWS
typedef unsigned long DWORD;
typedef DWORD * LPDWORD;
#ifdef _WIN64
typedef long long LONG_PTR;
typedef unsigned long long ULONG_PTR;
#else /* _WIN64 */
typedef long LONG_PTR;
typedef unsigned long ULONG_PTR;
#endif
typedef long LONG;
typedef wchar_t WCHAR;
typedef int BOOL;
typedef void VOID;
typedef void * HANDLE;
#ifndef MAX_PATH
#define MAX_PATH 260
#endif /* MAX_PATH */
#ifndef WINAPI
#define WINAPI __stdcall
#endif /* WINAPI */
#ifndef DECLSPEC_DLLIMPORT
#ifdef _MSC_VER
#define DECLSPEC_DLLIMPORT __declspec(dllimport)
#else /* _MSC_VER */
#define DECLSPEC_DLLIMPORT
#endif /* _MSC_VER */
#endif /* DECLSPEC_DLLIMPORT */
#ifndef WINBASEAPI
#define WINBASEAPI DECLSPEC_DLLIMPORT
#endif /* WINBASEAPI */
#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
#endif /* INVALID_HANDLE_VALUE */
#ifndef SYNCHRONIZE
#define SYNCHRONIZE (0x00100000L)
#endif /* SYNCHRONIZE */
#ifndef PROCESS_QUERY_INFORMATION
#define PROCESS_QUERY_INFORMATION (0x0400)
#endif /* PROCESS_QUERY_INFORMATION */
#ifndef INFINITE
#define INFINITE 0xFFFFFFFF
#endif /* INFINITE */
#ifndef WAIT_TIMEOUT
#define WAIT_TIMEOUT 258L
#endif /* WAIT_TIMEOUT */
/*
FIXME: causes FILETIME to conflict
#ifndef _FILETIME_
#define _FILETIME_
typedef struct FILETIME {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME, *PFILETIME, *LPFILETIME;
#endif
*/
WINBASEAPI DWORD WINAPI GetCurrentProcessId(VOID);
WINBASEAPI BOOL WINAPI CloseHandle(HANDLE hObject);
WINBASEAPI HANDLE WINAPI OpenProcess(DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwProcessId);
WINBASEAPI DWORD WINAPI WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds);
WINBASEAPI BOOL WINAPI GetExitCodeProcess(HANDLE hProcess, LPDWORD lpExitCode);
/*
FIXME: causes FILETIME to conflict
WINBASEAPI BOOL WINAPI GetProcessTimes(HANDLE hProcess, LPFILETIME lpCreationTime, LPFILETIME lpExitTime, LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
*/
#endif /* _INC_WINDOWS */
#ifndef _WINSOCKAPI_
struct private_timeval {
long tv_sec;
long tv_usec;
};
#define timeval private_timeval
#endif /* _WINSOCKAPI_ */
#ifndef _INC_TOOLHELP32
typedef struct tagPROCESSENTRY32W
{
DWORD dwSize;
DWORD cntUsage;
DWORD th32ProcessID;
ULONG_PTR th32DefaultHeapID;
DWORD th32ModuleID;
DWORD cntThreads;
DWORD th32ParentProcessID;
LONG pcPriClassBase;
DWORD dwFlags;
WCHAR szExeFile[MAX_PATH];
} PROCESSENTRY32W;
typedef PROCESSENTRY32W * PPROCESSENTRY32W;
typedef PROCESSENTRY32W * LPPROCESSENTRY32W;
#ifndef TH32CS_SNAPPROCESS
#define TH32CS_SNAPPROCESS 2
#endif /* TH32CS_SNAPPROCESS */
HANDLE WINAPI CreateToolhelp32Snapshot(DWORD dwFlags, DWORD th32ProcessID);
BOOL WINAPI Process32FirstW(HANDLE hSnapshot, LPPROCESSENTRY32W lppe);
BOOL WINAPI Process32NextW(HANDLE hSnapshot, LPPROCESSENTRY32W lppe);
#endif /* _INC_TOOLHELP32 */
#ifndef WNOHANG
#define WNOHANG 1
#endif /* WNOHANG */
#ifndef WUNTRACED
#define WUNTRACED 2
#endif /* WUNTRACED */
#ifndef __WEXITSTATUS
#define __WEXITSTATUS(status) (((status) & 0xFF00) >> 8)
#endif /* __WEXITSTATUS */
#ifndef __WIFEXITED
#define __WIFEXITED(status) (__WTERMSIG(status) == 0)
#endif /* __WIFEXITED */
#ifndef __WTERMSIG
#define __WTERMSIG(status) ((status) & 0x7F)
#endif /* __WTERMSIG */
#ifndef __WIFSIGNALED
#define __WIFSIGNALED(status) (((signed char)(__WTERMSIG(status) + 1) >> 1) > 0)
#endif /* __WIFSIGNALED */
#ifndef __WIFSTOPPED
#define __WIFSTOPPED(status) (((status) & 0xFF) == 0x7F)
#endif /* __WIFSTOPPED */
#ifndef __WSTOPSIG
#define __WSTOPSIG(status) __WEXITSTATUS(status)
#endif /* __WSTOPSIG */
#ifndef __WCONTINUED
#define __WCONTINUED 8
#endif /* __WCONTINUED */
#ifndef __WNOWAIT
#define __WNOWAIT 0x01000000
#endif /* __WNOWAIT */
#ifndef WEXITSTATUS
#define WEXITSTATUS(status) __WEXITSTATUS(status)
#endif /* WEXITSTATUS */
#ifndef WIFEXITED
#define WIFEXITED(status) __WIFEXITED(status)
#endif /* WIFEXITED */
#ifndef WIFSIGNALED
#define WIFSIGNALED(status) __WIFSIGNALED(status)
#endif /* WIFSIGNALED */
#ifndef WTERMSIG
#define WTERMSIG(status) __WTERMSIG(status)
#endif /* WTERMSIG */
#ifndef WIFSTOPPED
#define WIFSTOPPED(status) __WIFSTOPPED(status)
#endif /* WIFSTOPPED */
#ifndef WSTOPSIG
#define WSTOPSIG(status) __WSTOPSIG(status)
#endif /* WSTOPSIG */
#if !defined(__pid_t_defined) && !defined(_PID_T_) && !defined(pid_t)
#define __pid_t_defined 1
#define _PID_T_
typedef int __pid_t;
typedef __pid_t pid_t;
#endif /* !defined(__pid_t_defined) && !defined(_PID_T_) && !defined(pid_t) */
#ifndef __id_t_defined
#define __id_t_defined 1
typedef unsigned __id_t;
typedef __id_t id_t;
#endif /* __id_t_defined */
#ifndef __uid_t_defined
#define __uid_t_defined 1
typedef unsigned __uid_t;
typedef __uid_t uid_t;
#endif /* __uid_t_defined */
#ifndef __siginfo_t_defined
#define __siginfo_t_defined 1
typedef struct
{
int si_signo; /* signal number */
int si_code; /* signal code */
int si_errno; /* if non-zero, errno associated with this signal, as defined in <errno.h> */
pid_t si_pid; /* sending process ID */
uid_t si_uid; /* real user ID of sending process */
void * si_addr; /* address of faulting instruction */
int si_status; /* exit value of signal */
long si_band; /* band event of SIGPOLL */
}
siginfo_t;
#endif /* __siginfo_t_defined */
struct rusage
{
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
};
#ifndef __W_CONTINUED
#define __W_CONTINUED 0xFFFF
#endif /* __W_CONTINUED */
#ifndef __WIFCONTINUED
#define __WIFCONTINUED(status) ((status) == __W_CONTINUED)
#endif /* __WIFCONTINUED */
#ifndef WIFCONTINUED
#define WIFCONTINUED(status) __WIFCONTINUED(status)
#endif /* WIFCONTINUED */
#ifndef WSTOPPED
#define WSTOPPED 2
#endif /* WSTOPPED */
#ifndef WEXITED
#define WEXITED 4
#endif /* WEXITED */
#ifndef WCONTINUED
#define WCONTINUED __WCONTINUED
#endif /* WCONTINUED */
#ifndef WNOWAIT
#define WNOWAIT __WNOWAIT
#endif /* WNOWAIT */
typedef enum
{
P_ALL,
P_PID,
P_PGID
}
idtype_t;
int __filter_anychild (PROCESSENTRY32W * pe, DWORD pid);
int __filter_pid (PROCESSENTRY32W * pe, DWORD pid);
int __waitpid_internal (pid_t pid, int * status, int options,
siginfo_t * infop, struct rusage * rusage);
int waitpid (pid_t pid, int * status, int options);
int wait (int *status);
#ifdef _XOPEN_SOURCE
int waitid (idtype_t idtype, id_t id, siginfo_t * infop, int options);
pid_t wait3 (int * status, int options, struct rusage * rusage);
pid_t wait4 (pid_t pid, int * status, int options, struct rusage * rusage);
#endif /* _XOPEN_SOURCE */
#ifndef _INC_WINDOWS
#undef WAIT_OBJECT_0
#undef FILETIME
#undef PFILETIME
#undef LPFILETIME
#endif /* _INC_WINDOWS */
#ifndef _WINSOCKAPI_
#undef timeval
#endif /* _WINSOCKAPI_ */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* WIN32 */
#endif /* SYS_WAIT_H */