| 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 |
|
} |
| 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; |
| 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 |
|
} |
| 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); |