60 |
|
|
61 |
|
int warnings = 1; /* print warnings? */ |
62 |
|
|
63 |
+ |
int done_rprocs(struct rtproc *rtp); |
64 |
|
void init(int np); |
65 |
|
void filter(register FILE *infp, char *name); |
66 |
|
void xoptions(char *s, char *nm); |
158 |
|
} |
159 |
|
|
160 |
|
static void |
161 |
< |
killpersist(void) /* kill persistent process */ |
161 |
> |
killpersist(void) /* kill persistent rtrace process */ |
162 |
|
{ |
163 |
|
FILE *fp = fopen(persistfn, "r"); |
164 |
|
int pid; |
170 |
|
fclose(fp); |
171 |
|
} |
172 |
|
|
173 |
+ |
int |
174 |
+ |
done_rprocs(struct rtproc *rtp) |
175 |
+ |
{ |
176 |
+ |
int st0, st1 = 0; |
177 |
+ |
|
178 |
+ |
if (rtp->next != NULL) { /* close last opened first! */ |
179 |
+ |
st1 = done_rprocs(rtp->next); |
180 |
+ |
free((void *)rtp->next); |
181 |
+ |
rtp->next = NULL; |
182 |
+ |
} |
183 |
+ |
st0 = close_process(&rtp->pd); |
184 |
+ |
if (st0 < 0) |
185 |
+ |
error(WARNING, "unknown return status from rtrace process"); |
186 |
+ |
else if (st0 > 0) |
187 |
+ |
return(st0); |
188 |
+ |
return(st1); |
189 |
+ |
} |
190 |
+ |
|
191 |
|
void |
192 |
|
quit(int status) /* exit with status */ |
193 |
|
{ |
175 |
– |
struct rtproc *rtp; |
194 |
|
int rtstat; |
195 |
|
|
196 |
|
if (rt0.next != NULL) /* terminate persistent rtrace */ |
197 |
|
killpersist(); |
198 |
|
/* clean up rtrace process(es) */ |
199 |
< |
for (rtp = &rt0; rtp != NULL; rtp = rtp->next) { |
200 |
< |
rtstat = close_process(&rtp->pd); |
201 |
< |
if (status == 0) { |
184 |
< |
if (rtstat < 0) |
185 |
< |
error(WARNING, |
186 |
< |
"unknown return status from rtrace process"); |
187 |
< |
else |
188 |
< |
status = rtstat; |
189 |
< |
} |
190 |
< |
} |
199 |
> |
rtstat = done_rprocs(&rt0); |
200 |
> |
if (status == 0) |
201 |
> |
status = rtstat; |
202 |
|
exit(status); |
203 |
|
} |
204 |
|
|
227 |
|
} |
228 |
|
if (maxbytes < 0) |
229 |
|
error(SYSTEM, "cannot start rtrace process"); |
219 |
– |
if (!i && np > 1) |
220 |
– |
sleep(2); /* wait for persist file */ |
230 |
|
rtp->bsiz = maxbytes/(6*sizeof(float)); |
231 |
|
rtp->buf = (float *)malloc(6*sizeof(float)*rtp->bsiz--); |
232 |
|
rtp->dest = (float **)calloc(rtp->bsiz, sizeof(float *)); |
235 |
|
rtp->nrays = 0; |
236 |
|
if (i == np) /* last process? */ |
237 |
|
break; |
238 |
+ |
if (np > 1) |
239 |
+ |
sleep(2); /* wait for persist file */ |
240 |
|
rtp->next = (struct rtproc *)malloc(sizeof(struct rtproc)); |
241 |
|
if (rtp->next == NULL) |
242 |
|
error(SYSTEM, "out of memory in init"); |