543 |
|
static int |
544 |
|
spawned_children(int np) |
545 |
|
{ |
546 |
< |
long inpwidth = 0; |
546 |
> |
size_t recsize = 0; |
547 |
|
int i, rv; |
548 |
|
|
549 |
|
#if defined(_WIN32) || defined(_WIN64) |
559 |
|
mop[i].imx.nrows = 1; |
560 |
|
if (!rmx_prepare(&mop[i].imx)) |
561 |
|
goto memerror; |
562 |
< |
inpwidth += rmx_array_size(&mop[i].imx); |
562 |
> |
recsize += rmx_array_size(&mop[i].imx); |
563 |
|
if (mop[i].rmp != &mop[i].imx) { |
564 |
|
mop[i].rmp->nrows = 1; |
565 |
|
if (!rmx_prepare(mop[i].rmp)) |
566 |
|
goto memerror; |
567 |
– |
inpwidth += rmx_array_size(mop[i].rmp); |
567 |
|
} |
568 |
|
} |
569 |
|
/* prep output row buffer */ |
600 |
|
cproc[i].pid = -1; |
601 |
|
rv = open_process(&cproc[i], NULL); |
602 |
|
if (rv <= 0) break; |
603 |
< |
if (!i && 2*rv >= inpwidth) { |
603 |
> |
if (!i && 2*rv >= recsize) { |
604 |
|
fputs("Problem too small for multi-processing\n", |
605 |
|
stderr); |
606 |
+ |
close_processes(cproc, 1); |
607 |
|
exit(1); |
608 |
|
} |
609 |
|
} |
610 |
– |
if (rv > 0) |
611 |
– |
return(1); /* parent return value */ |
610 |
|
if (rv < 0) { |
611 |
|
perror("fork"); |
612 |
+ |
close_processes(cproc, i); |
613 |
|
exit(1); |
614 |
|
} |
615 |
+ |
if (rv > 0) /* parent return? */ |
616 |
+ |
return(1); |
617 |
|
inchild = i; /* our child index */ |
618 |
|
while (i-- > 0) /* don't share siblings' pipes */ |
619 |
|
close(cproc[i].w); |