[BACK]Return to job.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/job.c between version 1.87 and 1.88

version 1.87, 2007/09/23 12:53:21 version 1.88, 2007/09/23 14:58:50
Line 108 
Line 108 
 #include "memory.h"  #include "memory.h"
 #include "make.h"  #include "make.h"
   
 #define TMPPAT  "/tmp/makeXXXXXXXXXX"  
   
 /*  /*
  * The SEL_ constants determine the maximum amount of time spent in select   * The SEL_ constants determine the maximum amount of time spent in select
  * before coming out to see if a child has finished. SEL_SEC is the number of   * before coming out to see if a child has finished. SEL_SEC is the number of
Line 201 
Line 199 
 #define JOB_FINISHED    2       /* The job is already finished */  #define JOB_FINISHED    2       /* The job is already finished */
 #define JOB_STOPPED     3       /* The job is stopped */  #define JOB_STOPPED     3       /* The job is stopped */
   
 /*  
  * tfile is the name of a file into which all shell commands are put. It is  
  * used over by removing it before the child shell is executed. The XXXXXXXXXX  
  * in the string are replaced by mkstemp(3).  
  */  
 static char     tfile[sizeof(TMPPAT)];  
   
   
 #define SHELL_ECHO_OFF  "set -"  #define SHELL_ECHO_OFF  "set -"
 #define SHELL_ECHO_ON   "set -v"  #define SHELL_ECHO_ON   "set -v"
 #define SHELL_ERROR_ON  "set -e"  #define SHELL_ERROR_ON  "set -e"
Line 297 
Line 287 
 static void JobRestartJobs(void);  static void JobRestartJobs(void);
 static void DBPRINTF(Job *, const char *, ...);  static void DBPRINTF(Job *, const char *, ...);
 static void debug_printf(const char *, ...);  static void debug_printf(const char *, ...);
   static FILE *new_command_file(void);
   
 static volatile sig_atomic_t got_SIGINT, got_SIGHUP, got_SIGQUIT,  static volatile sig_atomic_t got_SIGINT, got_SIGHUP, got_SIGQUIT,
     got_SIGTERM;      got_SIGTERM;
Line 305 
Line 296 
     got_SIGWINCH;      got_SIGWINCH;
 #endif  #endif
   
   #define TMPPAT  "/tmp/makeXXXXXXXXXX"
   
   static FILE *
   new_command_file()
   {
           int fd;
           FILE *f;
           char tmp[] = TMPPAT;
   
           fd = mkstemp(tmp);
           if (fd == -1)
                   return NULL;
           f = fdopen(fd, "w");
           if (f == NULL)
                   close(fd);
           eunlink(tmp);
           return f;
   }
   
 static void  static void
 SigHandler(int sig)  SigHandler(int sig)
 {  {
Line 890 
Line 900 
                 /*                  /*
                  * If we are aborting and the job table is now empty, we finish.                   * If we are aborting and the job table is now empty, we finish.
                  */                   */
                 (void)eunlink(tfile);  
                 Finish(errors);                  Finish(errors);
         }          }
 }  }
Line 1224 
Line 1233 
                         DieHorribly();                          DieHorribly();
                 }                  }
   
                 job->cmdFILE = fopen(tfile, "w+");                  job->cmdFILE = new_command_file();
                 if (job->cmdFILE == NULL) {                  if (job->cmdFILE == NULL) {
                         Punt("Could not open %s", tfile);                          Punt("Error creating command file");
                 }                  }
                 (void)fcntl(fileno(job->cmdFILE), F_SETFD, 1);                  (void)fcntl(fileno(job->cmdFILE), F_SETFD, 1);
                 /*                  /*
Line 1296 
Line 1305 
                  * Unlink and close the command file if we opened one                   * Unlink and close the command file if we opened one
                  */                   */
                 if (job->cmdFILE != stdout) {                  if (job->cmdFILE != stdout) {
                         (void)eunlink(tfile);  
                         if (job->cmdFILE != NULL)                          if (job->cmdFILE != NULL)
                                 (void)fclose(job->cmdFILE);                                  (void)fclose(job->cmdFILE);
                 } else {                  } else {
Line 1321 
Line 1329 
                 }                  }
         } else {          } else {
                 (void)fflush(job->cmdFILE);                  (void)fflush(job->cmdFILE);
                 (void)eunlink(tfile);  
         }          }
   
         /*          /*
Line 1711 
Line 1718 
 void  void
 Job_Init(int maxproc)  Job_Init(int maxproc)
 {  {
         int tfd;  
   
         (void)strlcpy(tfile, TMPPAT, sizeof(tfile));  
         if ((tfd = mkstemp(tfile)) == -1)  
                 Punt("Cannot create temp file: %s", strerror(errno));  
         else  
                 (void)close(tfd);  
   
         Static_Lst_Init(&jobs);          Static_Lst_Init(&jobs);
         Static_Lst_Init(&stoppedJobs);          Static_Lst_Init(&stoppedJobs);
         maxJobs =         maxproc;          maxJobs =         maxproc;
Line 1884 
Line 1883 
                         }                          }
                 }                  }
         }          }
         (void)eunlink(tfile);  
         exit(signo);          exit(signo);
 }  }
   
Line 1897 
Line 1895 
  * Results:   * Results:
  *      Number of errors reported.   *      Number of errors reported.
  *   *
  * Side Effects:  
  *      The process' temporary file (tfile) is removed if it still  
  *      existed.  
  *-----------------------------------------------------------------------   *-----------------------------------------------------------------------
  */   */
 int  int
Line 1917 
Line 1912 
                         }                          }
                 }                  }
         }          }
         (void)eunlink(tfile);  
         return errors;          return errors;
 }  }
   
Line 1988 
Line 1982 
          */           */
         while (waitpid(-1, &foo, WNOHANG) > 0)          while (waitpid(-1, &foo, WNOHANG) > 0)
                 continue;                  continue;
         (void)eunlink(tfile);  
 }  }
   
 /*-  /*-

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.88