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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines