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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines