[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.86 and 1.87

version 1.86, 2007/09/23 12:51:59 version 1.87, 2007/09/23 12:53:21
Line 163 
Line 163 
 #define JOB_SPECIAL     0x004   /* Target is a special one. */  #define JOB_SPECIAL     0x004   /* Target is a special one. */
 #define JOB_IGNDOTS     0x008   /* Ignore "..." lines when processing  #define JOB_IGNDOTS     0x008   /* Ignore "..." lines when processing
                                  * commands */                                   * commands */
 #define JOB_FIRST       0x020   /* Job is first job for the node */  
 #define JOB_RESTART     0x080   /* Job needs to be completely restarted */  #define JOB_RESTART     0x080   /* Job needs to be completely restarted */
 #define JOB_RESUME      0x100   /* Job needs to be resumed b/c it stopped,  #define JOB_RESUME      0x100   /* Job needs to be resumed b/c it stopped,
                                  * for some reason */                                   * for some reason */
Line 930 
Line 929 
          * banner with their name in it never appears). This is an attempt to           * banner with their name in it never appears). This is an attempt to
          * provide that feedback, even if nothing follows it.           * provide that feedback, even if nothing follows it.
          */           */
         if (lastNode != job->node && (job->flags & JOB_FIRST) &&          if (lastNode != job->node && !(job->flags & JOB_SILENT)) {
             !(job->flags & JOB_SILENT)) {  
                 MESSAGE(stdout, job->node);                  MESSAGE(stdout, job->node);
                 lastNode = job->node;                  lastNode = job->node;
         }          }
Line 988 
Line 986 
         } else {          } else {
                 job->pid = cpid;                  job->pid = cpid;
   
                 if (job->flags & JOB_FIRST) {                  /* we set the current position in the buffer to the beginning
                         /*                   * and mark another stream to watch in the outputs mask
                          * The first time a job is run for a node, we set the                   */
                          * current position in the buffer to the beginning and                  job->curPos = 0;
                          * mark another stream to watch in the outputs mask  
                          */  
                         job->curPos = 0;  
   
                         if (outputsp == NULL || job->inPipe > outputsn) {                  if (outputsp == NULL || job->inPipe > outputsn) {
                                 int bytes, obytes;                          int bytes, obytes;
                                 char *tmp;                          char *tmp;
   
                                 bytes = howmany(job->inPipe+1, NFDBITS) *                          bytes = howmany(job->inPipe+1, NFDBITS) *
                                     sizeof(fd_mask);                              sizeof(fd_mask);
                                 obytes = outputsn ?                          obytes = outputsn ?
                                     howmany(outputsn+1, NFDBITS) *                              howmany(outputsn+1, NFDBITS) *
                                     sizeof(fd_mask) : 0;                              sizeof(fd_mask) : 0;
   
                                 if (bytes != obytes) {                          if (bytes != obytes) {
                                         tmp = realloc(outputsp, bytes);                                  tmp = realloc(outputsp, bytes);
                                         if (tmp == NULL)                                  if (tmp == NULL)
                                                 return;                                          return;
                                         memset(tmp + obytes, 0, bytes - obytes);                                  memset(tmp + obytes, 0, bytes - obytes);
                                         outputsp = (fd_set *)tmp;                                  outputsp = (fd_set *)tmp;
                                 }  
                                 outputsn = job->inPipe;  
                         }                          }
                         FD_SET(job->inPipe, outputsp);                          outputsn = job->inPipe;
                 }                  }
                   FD_SET(job->inPipe, outputsp);
   
                 /*                  /*
                  * XXX: Used to not happen if REMOTE. Why?                   * XXX: Used to not happen if REMOTE. Why?
Line 1186 
Line 1180 
         char *argv[4];          /* Argument vector to shell */          char *argv[4];          /* Argument vector to shell */
         bool cmdsOK;            /* true if the nodes commands were all right */          bool cmdsOK;            /* true if the nodes commands were all right */
         bool noExec;            /* Set true if we decide not to run the job */          bool noExec;            /* Set true if we decide not to run the job */
           int fd[2];
   
         job = emalloc(sizeof(Job));          job = emalloc(sizeof(Job));
         if (job == NULL) {          if (job == NULL) {
                 Punt("JobStart out of memory");                  Punt("JobStart out of memory");
         }          }
         flags |= JOB_FIRST;  
   
         job->node = gn;          job->node = gn;
         job->tailCmds = NULL;          job->tailCmds = NULL;
Line 1201 
Line 1195 
          * ones and the node's attributes... Any flags supplied by the caller           * ones and the node's attributes... Any flags supplied by the caller
          * are also added to the field.           * are also added to the field.
          */           */
         job->flags = 0;          job->flags = flags;
         if (Targ_Ignore(gn)) {          if (Targ_Ignore(gn)) {
                 job->flags |= JOB_IGNERR;                  job->flags |= JOB_IGNERR;
         }          }
         if (Targ_Silent(gn)) {          if (Targ_Silent(gn)) {
                 job->flags |= JOB_SILENT;                  job->flags |= JOB_SILENT;
         }          }
         job->flags |= flags;  
   
         /*          /*
          * Check the commands now so any attributes from .DEFAULT have a chance           * Check the commands now so any attributes from .DEFAULT have a chance
          * to migrate to the node           * to migrate to the node
          */           */
         if (job->flags & JOB_FIRST) {          cmdsOK = Job_CheckCommands(gn, Error);
                 cmdsOK = Job_CheckCommands(gn, Error);  
         } else {  
                 cmdsOK = true;  
         }  
   
         /*          /*
          * If the -n flag wasn't given, we open up OUR (not the child's)           * If the -n flag wasn't given, we open up OUR (not the child's)
Line 1295 
Line 1284 
                  * does no harm to keep working up the graph.                   * does no harm to keep working up the graph.
                  */                   */
                 job->cmdFILE = stdout;                  job->cmdFILE = stdout;
                 Job_Touch(gn, job->flags&JOB_SILENT);                  Job_Touch(gn, job->flags & JOB_SILENT);
                 noExec = true;                  noExec = true;
         }          }
   
Line 1346 
Line 1335 
          * get the shell's output. If we're using files, print out that we're           * get the shell's output. If we're using files, print out that we're
          * starting a job and then set up its temporary-file name.           * starting a job and then set up its temporary-file name.
          */           */
         if (job->flags & JOB_FIRST) {          if (pipe(fd) == -1)
                 int fd[2];                  Punt("Cannot create pipe: %s", strerror(errno));
                 if (pipe(fd) == -1)          job->inPipe = fd[0];
                         Punt("Cannot create pipe: %s", strerror(errno));          job->outPipe = fd[1];
                 job->inPipe = fd[0];          (void)fcntl(job->inPipe, F_SETFD, 1);
                 job->outPipe = fd[1];          (void)fcntl(job->outPipe, F_SETFD, 1);
                 (void)fcntl(job->inPipe, F_SETFD, 1);  
                 (void)fcntl(job->outPipe, F_SETFD, 1);  
         }  
   
         if (nJobs >= maxJobs && !(job->flags & JOB_SPECIAL) &&          if (nJobs >= maxJobs && !(job->flags & JOB_SPECIAL) &&
             maxJobs != 0) {              maxJobs != 0) {

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