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

Comparing ray/src/util/rcomb.c (file contents):
Revision 2.10 by greg, Mon May 20 23:21:29 2024 UTC vs.
Revision 2.11 by greg, Tue May 21 16:27:26 2024 UTC

# Line 605 | Line 605 | spawned_children(int np)
605                  perror("fork");
606                  exit(1);
607          }
608 <        inchild = i;            /* child index */
608 >        inchild = i;            /* our child index */
609 >        while (i-- > 0)         /* don't share siblings' pipes */
610 >                close(cproc[i].w);
611          fpurge(stdin);          /* discard previous matrix input */
612   #ifdef getc_unlocked
613          flockfile(stdin);
614   #endif
615          for (i = 0; i < nmats; i++) {
616                  if (mop[i].infp != stdin)
617 <                        fclose(mop[i].infp);
617 >                        fclose(mop[i].infp);    /* ! pclose() */
618                  mop[i].infp = stdin;
619                  mop[i].imx.dtype = DTdouble;
620          }
# Line 642 | Line 644 | parent_loop()
644   #endif
645          for (cur_row = 0; (in_nrows <= 0) | (cur_row < in_nrows); cur_row++) {
646              FILE        *ofp = outfp[cur_row % nchildren];
647 <            for (i = 0; i < nmats; i++) {
647 >            for (i = 0; i < nmats; i++)
648                  if (!rmx_load_row(mop[i].imx.mtx, &mop[i].imx, mop[i].infp)) {
649                          if (cur_row > in_nrows) /* unknown #input rows? */
650                                  break;
# Line 650 | Line 652 | parent_loop()
652                                          mop[i].inspec, cur_row);
653                          return(0);
654                  }
655 +            if (i < nmats)
656 +                break;
657 +            for (i = 0; i < nmats; i++)
658                  if (!rmx_write_data(mop[i].imx.mtx, mop[i].imx.ncomp,
659                                  mop[i].imx.ncols, DTdouble, ofp))
660                          return(0);
656            }
657            if (i < nmats)
658                break;
661              if (fflush(ofp) == EOF)
662                  return(0);
663          }
# Line 989 | Line 991 | main(int argc, char *argv[])
991                  return(1);
992          }
993          doptimize(1);                   /* optimize definitions */
994 <        if (spawned_children(nproc))    /* running in children? */
994 >        if (spawned_children(nproc))    /* running in parent process? */
995                  return(parent_loop() ? 0 : 1);
996                                          /* process & write rows */
997          return(combine_input() ? 0 : 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines