| 63 |
|
closestream(void *p) |
| 64 |
|
{ |
| 65 |
|
STREAMOUT *sop = (STREAMOUT *)p; |
| 66 |
+ |
int status; |
| 67 |
|
if (sop->reclen == CNT_PIPE) |
| 68 |
< |
pclose(sop->ofp); |
| 68 |
> |
status = pclose(sop->ofp); |
| 69 |
|
else |
| 70 |
< |
fclose(sop->ofp); |
| 70 |
> |
status = fclose(sop->ofp); |
| 71 |
> |
if (status) |
| 72 |
> |
error(SYSTEM, "error closing output stream"); |
| 73 |
|
free(p); |
| 74 |
|
} |
| 75 |
|
|
| 702 |
|
sop = (STREAMOUT *)malloc(sizeof(STREAMOUT)); |
| 703 |
|
if (sop == NULL) |
| 704 |
|
error(SYSTEM, "out of memory in getostream"); |
| 705 |
< |
sop->reclen = oname[0] == '!' ? CNT_PIPE : 0; |
| 705 |
> |
sop->reclen = oname[0] == '!' ? CNT_PIPE : CNT_UNKNOWN; |
| 706 |
|
sop->ofp = NULL; /* open iff noopen==0 */ |
| 707 |
|
lep->data = (char *)sop; |
| 708 |
|
} |
| 709 |
|
if (!noopen && sop->ofp == NULL) { /* open output stream */ |
| 710 |
< |
int i; |
| 710 |
> |
long i; |
| 711 |
|
if (oname[0] == '!') /* output to command */ |
| 712 |
|
sop->ofp = popen(oname+1, "w"); |
| 713 |
|
else |
| 734 |
|
} |
| 735 |
|
printresolu(sop->ofp); |
| 736 |
|
/* play catch-up */ |
| 737 |
< |
for (i = 0; i < lastdone; i++) { |
| 737 |
> |
for (i = sop->reclen > 1 ? sop->reclen*lastdone : lastdone; |
| 738 |
> |
i--; ) { |
| 739 |
|
static const DCOLOR nocontrib = BLKCOLOR; |
| 740 |
|
put_contrib(nocontrib, sop->ofp); |
| 741 |
|
if (outfmt == 'a') |
| 1043 |
|
/* loop over input */ |
| 1044 |
|
while ((iblen = getinp(inpbuf, fin)) > 0) { |
| 1045 |
|
if (lastray+1 < lastray || /* need reset? */ |
| 1046 |
< |
queue_length() > 5*nrtprocs()) { |
| 1046 |
> |
queue_length() > 10*nrtprocs()) { |
| 1047 |
|
while (wait_rproc() != NULL) |
| 1048 |
|
process_queue(); |
| 1049 |
< |
lastdone = lastray = 0; |
| 1049 |
> |
if (lastray+1 < lastray) |
| 1050 |
> |
lastdone = lastray = 0; |
| 1051 |
|
} |
| 1052 |
|
rtp = get_rproc(); /* get avail. rtrace process */ |
| 1053 |
|
rtp->raynum = ++lastray; /* assign ray to it */ |
| 1130 |
|
if (oent->data != NULL) { |
| 1131 |
|
sout = *(STREAMOUT *)oent->data; |
| 1132 |
|
} else { |
| 1133 |
< |
sout.reclen = 0; |
| 1133 |
> |
sout.reclen = CNT_UNKNOWN; |
| 1134 |
|
sout.ofp = NULL; |
| 1135 |
|
} |
| 1136 |
|
if (sout.ofp != NULL) { /* already open? */ |