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.13 by schorsch, Mon Mar 28 16:59:38 2016 UTC vs.
Revision 3.14 by greg, Fri Feb 28 05:18:49 2020 UTC

# Line 21 | Line 21 | static char RCSid[]="$Id$";
21   #include "rtprocess.h"
22  
23  
24 + SUBPROC         sp_inactive;    /* zero initialization is fine */
25 +
26 +
27   int
28   win_nice(int inc) /* simple nice(2) replacement for Windows */
29   {
# Line 168 | Line 171 | start_process(SUBPROC *proc, char *cmdstr)
171          proc->r = _open_osfhandle((long)hRead, _O_RDONLY|_O_BINARY);
172          proc->w = _open_osfhandle((long)hWrite, _O_APPEND|_O_BINARY);
173          proc->pid = PInfo.dwProcessId;
174 <        proc->running = 1;
174 >        proc->flags = PF_RUNNING;
175          CloseHandle(hCurProc);
176          /* Windows doesn't tell us the actual buffer size */
177          return PIPE_BUF;
# Line 182 | Line 185 | error: /* cleanup */
185          if(hRead) CloseHandle(hRead);
186          if(hWrite) CloseHandle(hWrite);
187          if(hCurProc) CloseHandle(hCurProc);
188 <        proc->running = 0;
188 >        proc->flags = 0;
189          return -1;
190          /* There... Are we happy now? */
191   }
# Line 277 | Line 280 | open_process(SUBPROC *proc, char *av[])
280          char *cmdpath;
281          char *cmdstr;
282  
283 <        if (av == NULL || av[0] == NULL) {
283 >        if (av == NULL || av[0] == NULL || proc->flags) {
284                  fputs("Illegal call to open_process()!\n", stderr);
285                  return -1;
286          }
287          proc->pid = 0;
285        proc->running = 0;
288          if (av == NULL) { return -1; }
289          cmdpath = getpath(av[0], getenv("PATH"), X_OK);
290          cmdstr = quoted_cmdline(cmdpath, av+1);
# Line 311 | Line 313 | close_processes(SUBPROC pd[], int nproc) {
313          DWORD pid;
314  
315          for (i = 0; i < nproc; i++) {
316 <                if (pd[i].running) {
316 >                if (pd[i].flags & PF_RUNNING) {
317                          ocres = close(pd[i].w);
318                          icres = close(pd[i].r);
319 <                        pd[i].running = 0;
319 >                        pd[i].flags = 0;
320                          if(ocres != 0 || icres != 0) {
321                                  /* something went wrong: enforce infanticide */
322                                  /* other than that, it looks like we want to ignore errors */
# Line 337 | Line 339 | main( int argc, char **argv )
339          char ret[1024];
340          char *command[]= {"word", "gappy word", "\"quoted words\"", "'squoted words'", NULL};
341  
342 <    res = open_process(&proc, command)
342 >        proc.flags = 0;
343 >        proc.pid = 0;
344 >        res = open_process(&proc, command)
345          if (res == 0) {
346                  printf("open_process() failed with return value 0\n");
347                  return -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines