| 507 |
|
fprintf(stderr, "%s: code Error 1 in multi_process()\n", gargv[0]); |
| 508 |
|
return(0); |
| 509 |
|
} |
| 510 |
< |
while (--coff > 0) { /* parent births children */ |
| 510 |
> |
fflush(NULL); /* parent births helper subprocs */ |
| 511 |
> |
while (--coff > 0) { |
| 512 |
|
int pid = fork(); |
| 513 |
|
if (pid < 0) { |
| 514 |
|
fprintf(stderr, "%s: fork() call failed!\n", gargv[0]); |
| 515 |
|
return(0); |
| 516 |
|
} |
| 517 |
< |
if (pid == 0) break; /* child gets to work */ |
| 517 |
> |
if (!pid) break; /* new child gets to work */ |
| 518 |
|
} |
| 519 |
|
if (!row0 | (out_type != DTfloat)) { |
| 520 |
|
osum = (float *)calloc((size_t)xres*yres, sizeof(float)*ncomp); |
| 640 |
|
goto writerr; |
| 641 |
|
odd = !odd; /* go back & forth to milk page cache */ |
| 642 |
|
} |
| 643 |
+ |
if (coff) _exit(0); /* child exits here */ |
| 644 |
+ |
/* but parent waits for children */ |
| 645 |
|
if (osum) free(osum); |
| 646 |
|
free(syarr); |
| 647 |
< |
if (coff) /* child exits here... */ |
| 645 |
< |
_exit(0); |
| 646 |
< |
c = 0; /* ...but parent waits for children */ |
| 647 |
> |
c = 0; |
| 648 |
|
while (++coff < nprocs) { |
| 649 |
|
int st; |
| 650 |
|
if (wait(&st) < 0) { |