ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/Development/ray/src/rt/rmain.c
(Generate patch)

Comparing ray/src/rt/rmain.c (file contents):
Revision 2.26 by greg, Fri Jul 30 12:09:37 1993 UTC vs.
Revision 2.27 by greg, Mon Aug 2 13:34:06 1993 UTC

# Line 33 | Line 33 | static char SCCSid[] = "$SunId$ LBL";
33  
34   #include  "paths.h"
35                                          /* persistent processes define */
36 + #define  NOPERS         0               /* do not persist (must be zero) */
37   #ifdef  F_SETLKW
38   #if  RPICT|RTRACE
39 < #define  PERSIST        1
39 > #define  PERSIST        1               /* normal persist */
40 > #define  PARALLEL       2               /* parallel persist */
41 > #define  PCHILD         3               /* child of normal persist */
42   #endif
43   #endif
44  
# Line 143 | Line 146 | char  *argv[];
146          char  *ambfile = NULL;
147          int  loadflags = ~IO_FILES;
148          int  seqstart = 0;
149 <        int  persist = 0;
149 >        int  persist = NOPERS;
150          char  **amblp;
151          char  **tralp;
152          int  duped1;
# Line 531 | Line 534 | char  *argv[];
534                  case 'P':                               /* persist file */
535                          if (argv[i][2] == 'P') {
536                                  check(3,"s");
537 <                                persist = 2;
537 >                                persist = PARALLEL;
538                          } else {
539                                  check(2,"s");
540 <                                persist = 1;
540 >                                persist = PERSIST;
541                          }
542                          persistfile(argv[++i]);
543                          break;
# Line 600 | Line 603 | char  *argv[];
603                  duped1 = dup(fileno(stdout));   /* don't lose our output */
604                  openheader();
605          }
603 #else
606   #if  RPICT
607 +        else
608 + #endif
609 + #endif
610 + #if  RPICT
611          if (outfile != NULL)
612                  openheader();
613   #endif
608 #endif
614   #ifdef  MSDOS
615   #if  RTRACE
616          if (outform != 'a')
# Line 637 | Line 642 | char  *argv[];
642                          dup2(duped1, fileno(stdout));
643                          close(duped1);
644                  }
645 <                if (persist == 2) {     /* multiprocessing */
645 >                if (persist == PARALLEL) {      /* multiprocessing */
646                          preload_objs();         /* preload scene */
647                          while ((rval=fork()) == 0) {    /* keep on forkin' */
648                                  pflock(1);
# Line 646 | Line 651 | char  *argv[];
651                          }
652                          if (rval < 0)
653                                  error(SYSTEM, "cannot fork child for persist function");
654 <                        pfdetach();
650 <                        persist = 0;            /* parent shan't persist */
651 <                        if (outfile == NULL)
652 <                                dupheader();
653 <                        else                    /* keep open so attach waits */
654 <                                duped1 = dup(fileno(stdout));
654 >                        pfdetach();             /* parent exits */
655                  }
656          }
657   runagain:
658 <        if (persist && outfile == NULL)
659 <                dupheader();
658 >        if (persist)
659 >                if (outfile == NULL)                    /* if out to stdout */
660 >                        dupheader();                    /* send header */
661 >                else                                    /* if out to file */
662 >                        duped1 = dup(fileno(stdout));   /* hang onto pipe */
663   #endif
664   #if  RPICT
665          rpict(seqstart, outfile, zfile, recover);
# Line 669 | Line 672 | runagain:
672   #endif
673          ambsync();                      /* flush ambient file */
674   #ifdef  PERSIST
675 <        if (persist == 1) {             /* first run-through */
675 >        if (persist == PERSIST) {       /* first run-through */
676                  if ((rval=fork()) == 0) {       /* child loops until killed */
677                          pflock(1);
678 <                        persist = -1;
678 >                        persist = PCHILD;
679                  } else {                        /* original process exits */
680                          if (rval < 0)
681                                  error(SYSTEM, "cannot fork child for persist function");
682 <                        pfdetach();
680 <                        persist = 0;
682 >                        pfdetach();             /* parent exits */
683                  }
684          }
685 <        if (persist) {                  /* wait for a signal then go again */
685 >        if (persist == PCHILD) {        /* wait for a signal then go again */
686 >                if (outfile != NULL)
687 >                        close(duped1);          /* release output handle */
688                  pfhold();
689                  tstart = time(0);               /* reinitialize counters */
690                  raynum = nrays = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)