ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/mkillum.c
(Generate patch)

Comparing ray/src/gen/mkillum.c (file contents):
Revision 2.21 by greg, Sun Sep 19 08:42:22 2004 UTC vs.
Revision 2.26 by schorsch, Mon Sep 19 11:30:10 2005 UTC

# Line 60 | Line 60 | int    doneheader = 0;         /* printed header yet? */
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);
# Line 156 | Line 157 | main(          /* compute illum distributions using rtrace */
157          quit(0);
158   }
159  
160 +
161 + #ifndef SIGALRM
162 + #define SIGALRM SIGTERM
163 + #endif
164   static void
165   killpersist(void)                       /* kill persistent rtrace process */
166   {
# Line 169 | Line 174 | killpersist(void)                      /* kill persistent rtrace process
174          fclose(fp);
175   }
176  
177 +
178 + int
179 + done_rprocs(struct rtproc *rtp)
180 + {
181 +        int     st0, st1 = 0;
182 +
183 +        if (rtp->next != NULL) {        /* close last opened first! */
184 +                st1 = done_rprocs(rtp->next);
185 +                free((void *)rtp->next);
186 +                rtp->next = NULL;
187 +        }
188 +        st0 = close_process(&rtp->pd);
189 +        if (st0 < 0)
190 +                error(WARNING, "unknown return status from rtrace process");
191 +        else if (st0 > 0)
192 +                return(st0);
193 +        return(st1);
194 + }
195 +
196   void
197   quit(int status)                        /* exit with status */
198   {
175        struct rtproc   *rtp;
199          int     rtstat;
200  
201          if (rt0.next != NULL)           /* terminate persistent rtrace */
202                  killpersist();
203                                          /* clean up rtrace process(es) */
204 <        for (rtp = &rt0; rtp != NULL; rtp = rtp->next) {
205 <                rtstat = close_process(&rtp->pd);
206 <                if (status == 0) {
184 <                        if (rtstat < 0)
185 <                                error(WARNING,
186 <                                "unknown return status from rtrace process");
187 <                        else
188 <                                status = rtstat;
189 <                }
190 <        }
204 >        rtstat = done_rprocs(&rt0);
205 >        if (status == 0)
206 >                status = rtstat;
207          exit(status);
208   }
209  
# Line 202 | Line 218 | init(int np)                           /* start rtrace and set up buffers */
218          ofun[OBJ_SPHERE].funp = o_sphere;
219          ofun[OBJ_RING].funp = o_ring;
220                                          /* set up signal handling */
221 < #ifdef SIGPIPE /* not present on Windows */
221 >        signal(SIGINT, quit);
222 > #ifdef SIGHUP
223 >        signal(SIGHUP, quit);
224 > #endif
225 > #ifdef SIGTERM
226 >        signal(SIGTERM, quit);
227 > #endif
228 > #ifdef SIGPIPE
229          signal(SIGPIPE, quit);
230   #endif
231          rtp = &rt0;                     /* start rtrace process(es) */
# Line 216 | Line 239 | init(int np)                           /* start rtrace and set up buffers */
239                  }
240                  if (maxbytes < 0)
241                          error(SYSTEM, "cannot start rtrace process");
219                if (!i && np > 1)
220                        sleep(2);       /* wait for persist file */
242                  rtp->bsiz = maxbytes/(6*sizeof(float));
243                  rtp->buf = (float *)malloc(6*sizeof(float)*rtp->bsiz--);
244                  rtp->dest = (float **)calloc(rtp->bsiz, sizeof(float *));
# Line 226 | Line 247 | init(int np)                           /* start rtrace and set up buffers */
247                  rtp->nrays = 0;
248                  if (i == np)            /* last process? */
249                          break;
250 +                if (np > 1)
251 +                        sleep(2);       /* wait for persist file */
252                  rtp->next = (struct rtproc *)malloc(sizeof(struct rtproc));
253                  if (rtp->next == NULL)
254                          error(SYSTEM, "out of memory in init");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines