ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/win_process.c
(Generate patch)

Comparing ray/src/common/win_process.c (file contents):
Revision 3.4 by schorsch, Tue Oct 21 19:19:28 2003 UTC vs.
Revision 3.7 by greg, Thu Jun 14 05:13:25 2012 UTC

# Line 185 | Line 185 | error: /* cleanup */
185          if(hWrite) CloseHandle(hWrite);
186          if(hCurProc) CloseHandle(hCurProc);
187          proc->running = 0;
188 <        return 0;
188 >        return -1;
189          /* There... Are we happy now? */
190   }
191  
# Line 280 | Line 280 | open_process(SUBPROC *proc, char *av[])
280          char *cmdstr;
281  
282          proc->running = 0;
283 +        if (av == NULL) { return -1; }
284          cmdpath = getpath(av[0], getenv("PATH"), X_OK);
285 <        cmdstr = quoted_cmdline(cmdpath, av);
285 >        cmdstr = quoted_cmdline(cmdpath, av+1);
286          if (cmdstr == NULL) { return 0; }
287          return start_process(proc, cmdstr);
288   }
289  
290  
291 + int win_kill(RT_PID pid, int sig) /* we ignore sig... */
292 + {
293 +        HANDLE hProc;
294 +
295 +        hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid);
296 +        /*  it looks like we want to ignore errors here */
297 +        if(hProc != NULL) {
298 + #ifdef OBSOLETE_WINDOWS
299 + #define KILL_TIMEOUT 10 * 1000 /* milliseconds */
300 +                /* it might have some windows open... */
301 +                EnumWindows((WNDENUMPROC)TerminateAppEnum, (LPARAM)pid);
302 +                if(WaitForSingleObject(hProc, KILL_TIMEOUT)!=WAIT_OBJECT_0) {
303 +                        /* No way to avoid dangling DLLs here. */
304 +                        TerminateProcess(hProc, 0);
305 +                }
306 + #else
307 +                SafeTerminateProcess(hProc, 0);
308 + #endif
309 +                /* WaitForSingleObject(hProc, 0); */
310 +                /* not much use to wait on Windows */
311 +                CloseHandle(hProc);
312 +        }
313 +        return 0; /* XXX we need to figure out more here... */
314 + }
315 +
316 +
317   int
318   close_process(SUBPROC *proc) {
319          int icres, ocres;
320          DWORD pid;
294        HANDLE hProc;
321  
322          ocres = close(proc->w);
323          icres = close(proc->r);
324          pid = proc->pid;
325          if(ocres != 0 || icres != 0) {
300                hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, pid);
326                  /* something went wrong: enforce infanticide */
327                  /* other than that, it looks like we want to ignore errors here */
328                  if (proc->running) {
329 <                        if(hProc != NULL) {
305 < #ifdef OBSOLETE_WINDOWS
306 < #define KILL_TIMEOUT 10 * 1000 /* milliseconds */
307 <                                /* it might have some windows open... */
308 <                                EnumWindows((WNDENUMPROC)TerminateAppEnum, (LPARAM)pid);
309 <                                if(WaitForSingleObject(hProc, KILL_TIMEOUT)!=WAIT_OBJECT_0) {
310 <                                        /* No way to avoid dangling DLLs here. */
311 <                                        TerminateProcess(hProc, 0);
312 <                                }
313 < #else
314 <                                SafeTerminateProcess(hProc, 0);
315 < #endif
316 <                                /* WaitForSingleObject(hProc, 0); */
317 <                                /* not much use to wait on Windows */
318 <                                CloseHandle(hProc);
319 <                        }
329 >                        win_kill(pid, 0);
330                  }
331          }
332          proc->running = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines