--- ray/src/common/win_process.c 2016/03/04 02:48:14 3.10 +++ ray/src/common/win_process.c 2016/03/28 16:59:38 3.13 @@ -1,5 +1,5 @@ #ifndef lint -static char RCSid[]="$Id: win_process.c,v 3.10 2016/03/04 02:48:14 greg Exp $"; +static char RCSid[]="$Id: win_process.c,v 3.13 2016/03/28 16:59:38 schorsch Exp $"; #endif /* * Routines to communicate with separate process via dual pipes. @@ -38,7 +38,6 @@ win_nice(int inc) /* simple nice(2) replacement for Wi in the process that calls ExitProcess. As presented by Andrew Tucker in Windows Developer Magazine. */ -#ifndef OBSOLETE_WINDOWS /* won't work on Win 9X/ME/CE. */ BOOL SafeTerminateProcess(HANDLE hProcess, UINT uExitCode) { DWORD dwTID, dwCode, dwErr = 0; @@ -78,7 +77,6 @@ BOOL SafeTerminateProcess(HANDLE hProcess, UINT uExitC if ( !bSuccess ) SetLastError(dwErr); return bSuccess; } -#endif static int @@ -190,18 +188,18 @@ error: /* cleanup */ } -static int /* copied size or -1 on error */ +static size_t /* copied size or -1 on error */ wordncopy( /* copy (quoted) src to dest. */ char * dest, char * src, -int dlen, +size_t dlen, int insert_space, /* prepend a space */ int force_dq /* turn 'src' into "dest" (for Win command line) */ ) { - int slen; - int pos = 0; + size_t slen; + size_t pos = 0; slen = strlen(src); if (insert_space) { @@ -245,9 +243,9 @@ char *sl[] /* list of arguments */ ) { static char *cmdstr; - static int clen; + static size_t clen; char *newcs; - int newlen, pos, res, i; + size_t newlen, pos, i, res; newlen = strlen(cmdpath) + 3; /* allow two quotes plus the final \0 */ for (i = 0; sl[i] != NULL; i++) { @@ -300,19 +298,7 @@ int win_kill(RT_PID pid, int sig) /* we ignore sig... hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid); /* it looks like we want to ignore errors here */ if(hProc != NULL) { -#ifdef OBSOLETE_WINDOWS -#define KILL_TIMEOUT 10 * 1000 /* milliseconds */ - /* it might have some windows open... */ - EnumWindows((WNDENUMPROC)TerminateAppEnum, (LPARAM)pid); - if(WaitForSingleObject(hProc, KILL_TIMEOUT)!=WAIT_OBJECT_0) { - /* No way to avoid dangling DLLs here. */ - TerminateProcess(hProc, 0); - } -#else SafeTerminateProcess(hProc, 0); -#endif - /* WaitForSingleObject(hProc, 0); */ - /* not much use to wait on Windows */ CloseHandle(hProc); } return 0; /* XXX we need to figure out more here... */ @@ -325,15 +311,15 @@ close_processes(SUBPROC pd[], int nproc) { DWORD pid; for (i = 0; i < nproc; i++) { - if (pid[i].running) { + if (pd[i].running) { ocres = close(pd[i].w); icres = close(pd[i].r); pd[i].running = 0; - } - if(ocres != 0 || icres != 0) { - /* something went wrong: enforce infanticide */ - /* other than that, it looks like we want to ignore errors here */ - win_kill(pd[i].pid, 0); + if(ocres != 0 || icres != 0) { + /* something went wrong: enforce infanticide */ + /* other than that, it looks like we want to ignore errors */ + win_kill(pd[i].pid, 0); + } } pd[i].pid = 0; }