MCPcopy Create free account
hub / github.com/git/git / waitpid

Function waitpid

compat/mingw.c:3001–3051  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2999}
3000
3001pid_t waitpid(pid_t pid, int *status, int options)
3002{
3003 HANDLE h = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION,
3004 FALSE, pid);
3005 if (!h) {
3006 errno = ECHILD;
3007 return -1;
3008 }
3009
3010 if (pid > 0 && options & WNOHANG) {
3011 if (WAIT_OBJECT_0 != WaitForSingleObject(h, 0)) {
3012 CloseHandle(h);
3013 return 0;
3014 }
3015 options &= ~WNOHANG;
3016 }
3017
3018 if (options == 0) {
3019 struct pinfo_t **ppinfo;
3020 if (WaitForSingleObject(h, INFINITE) != WAIT_OBJECT_0) {
3021 CloseHandle(h);
3022 return 0;
3023 }
3024
3025 if (status)
3026 GetExitCodeProcess(h, (LPDWORD)status);
3027
3028 EnterCriticalSection(&pinfo_cs);
3029
3030 ppinfo = &pinfo;
3031 while (*ppinfo) {
3032 struct pinfo_t *info = *ppinfo;
3033 if (info->pid == pid) {
3034 CloseHandle(info->proc);
3035 *ppinfo = info->next;
3036 free(info);
3037 break;
3038 }
3039 ppinfo = &info->next;
3040 }
3041
3042 LeaveCriticalSection(&pinfo_cs);
3043
3044 CloseHandle(h);
3045 return pid;
3046 }
3047 CloseHandle(h);
3048
3049 errno = EINVAL;
3050 return -1;
3051}
3052
3053int xutftowcsn(wchar_t *wcs, const char *utfs, size_t wcslen, int utflen)
3054{

Callers 8

cleanup_childrenFunction · 0.85
wait_or_whineFunction · 0.85
start_bg_commandFunction · 0.85
tloop_joinFunction · 0.85
check_dead_childrenFunction · 0.85
try_shell_execFunction · 0.85
mingw_execvFunction · 0.85
executeFunction · 0.85

Calls

no outgoing calls

Tested by 1

executeFunction · 0.68