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.5 by schorsch, Sat Oct 23 18:55:52 2004 UTC vs.
Revision 3.12 by schorsch, Sun Mar 6 01:13:17 2016 UTC

# Line 167 | Line 167 | start_process(SUBPROC *proc, char *cmdstr)
167          CloseHandle(hFromChildWrite); hFromChildWrite = NULL;
168          CloseHandle(hToChildRead); hToChildRead = NULL;
169          /* get the file descriptors */
170 <        proc->r = _open_osfhandle((long)hRead, _O_RDONLY);
171 <        proc->w = _open_osfhandle((long)hWrite, _O_APPEND);
170 >        proc->r = _open_osfhandle((long)hRead, _O_RDONLY|_O_BINARY);
171 >        proc->w = _open_osfhandle((long)hWrite, _O_APPEND|_O_BINARY);
172          proc->pid = PInfo.dwProcessId;
173          proc->running = 1;
174          CloseHandle(hCurProc);
# 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  
192  
193 < static int         /* copied size or -1 on error */
193 > static size_t         /* copied size or -1 on error */
194   wordncopy(         /* copy (quoted) src to dest. */
195  
196   char * dest,
197   char * src,
198 < int dlen,
198 > size_t dlen,
199   int insert_space,  /* prepend a space  */
200   int force_dq       /* turn 'src' into "dest" (for Win command line) */
201   )
202   {
203 <        int slen;
204 <        int pos = 0;
203 >        size_t slen;
204 >        size_t pos = 0;
205  
206          slen = strlen(src);
207          if (insert_space) {
# Line 245 | Line 245 | char *sl[]       /* list of arguments */
245   )
246   {
247          static char *cmdstr;
248 <        static int clen;
248 >        static size_t clen;
249          char *newcs;
250 <        int newlen, pos, res, i;
250 >        size_t newlen, pos, i, res;
251  
252          newlen = strlen(cmdpath) + 3; /* allow two quotes plus the final \0 */
253          for (i = 0; sl[i] != NULL; i++) {
# 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->pid = 0;
287          proc->running = 0;
288 +        if (av == NULL) { return -1; }
289          cmdpath = getpath(av[0], getenv("PATH"), X_OK);
290 <        cmdstr = quoted_cmdline(cmdpath, av);
290 >        cmdstr = quoted_cmdline(cmdpath, av+1);
291          if (cmdstr == NULL) { return 0; }
292          return start_process(proc, cmdstr);
293   }
# Line 314 | Line 320 | int win_kill(RT_PID pid, int sig) /* we ignore sig...
320  
321  
322   int
323 < close_process(SUBPROC *proc) {
324 <        int icres, ocres;
323 > close_processes(SUBPROC pd[], int nproc) {
324 >        int i, icres, ocres;
325          DWORD pid;
326  
327 <        ocres = close(proc->w);
328 <        icres = close(proc->r);
329 <        pid = proc->pid;
330 <        if(ocres != 0 || icres != 0) {
331 <                /* something went wrong: enforce infanticide */
332 <                /* other than that, it looks like we want to ignore errors here */
333 <                if (proc->running) {
334 <                        int win_kill(pid, 0);
327 >        for (i = 0; i < nproc; i++) {
328 >                if (pd[i].running) {
329 >                        ocres = close(pd[i].w);
330 >                        icres = close(pd[i].r);
331 >                        pd[i].running = 0;
332 >                        if(ocres != 0 || icres != 0) {
333 >                                /* something went wrong: enforce infanticide */
334 >                                /* other than that, it looks like we want to ignore errors here */
335 >                                win_kill(pd[i].pid, 0);
336 >                        }
337                  }
338 +                pd[i].pid = 0;
339          }
331        proc->running = 0;
340          return 0; /* XXX we need to figure out more here... */
341   }
342  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines