Print this page
make: unifdef for other OSes (undefined)


  44 #       include <dm/Avo_MToolRsrcInfoMsg.h>
  45 #       include <dm/Avo_macro_defs.h> /* AVO_BLOCK_INTERUPTS & AVO_UNBLOCK_INTERUPTS */
  46 #       include <dmthread/Avo_ServerState.h>
  47 #       include <rw/pstream.h>
  48 #       include <rw/xdrstrea.h>
  49 #endif
  50 
  51 #include <fcntl.h>
  52 #include <mk/defs.h>
  53 #include <mksh/i18n.h>            /* get_char_semantics_value() */
  54 #include <mksh/macro.h>           /* getvar(), expand_value() */
  55 #include <mksh/misc.h>            /* getmem() */
  56 #include <poll.h>
  57 
  58 #ifdef PARALLEL
  59 #       include <rx/api.h>
  60 #endif
  61 
  62 #include <signal.h>
  63 
  64 #ifndef HP_UX
  65 #       include <stropts.h>
  66 #endif
  67 
  68 #include <sys/errno.h>
  69 #include <sys/stat.h>
  70 #include <sys/types.h>
  71 #include <sys/utsname.h>  /* uname() */
  72 #include <sys/wait.h>
  73 #include <unistd.h>               /* close() */
  74 
  75 /*
  76  * Defined macros
  77  */
  78 #ifndef PARALLEL
  79 #       define LOCALHOST "localhost"
  80 #endif
  81 
  82 #define MAXRULES 100
  83 
  84 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
  85 #define SEND_MTOOL_MSG(cmds) \
  86         if (send_mtool_msgs) { \


3542 int
3543 get_job_msg_id(void)
3544 {
3545         return job_msg_id;
3546 }
3547 
3548 // Continuously poll and show the results of remotely executing a job,
3549 // i.e., output the stdout and stderr files.
3550 
3551 static int
3552 pollResults(char *outFn, char *errFn, char *hostNm)
3553 {
3554         int             child;
3555 
3556         child = fork();
3557         switch (child) {
3558         case -1:
3559                 break;
3560         case 0:
3561                 enable_interrupt((void (*) (int))SIG_DFL);
3562 #ifdef linux
3563                 (void) signal(SIGUSR1, Avo_PollResultsAction_Sigusr1Handler);
3564 #else
3565                 (void) sigset(SIGUSR1, Avo_PollResultsAction_Sigusr1Handler);
3566 #endif
3567                 pollResultsAction(outFn, errFn);
3568 
3569                 exit(0);
3570                 break;
3571         default:
3572                 break;
3573         }
3574         return child;
3575 }
3576 
3577 // This is the PollResultsAction SIGUSR1 handler.
3578 
3579 static bool_t pollResultsActionTimeToFinish = FALSE;
3580 
3581 extern "C" void
3582 Avo_PollResultsAction_Sigusr1Handler(int foo)
3583 {
3584         pollResultsActionTimeToFinish = TRUE;
3585 }
3586 


3600                 us_sleep(STAT_RETRY_SLEEP_TIME);
3601         }
3602         // The previous stat() could be failed due to EINTR
3603         // So one more try is needed
3604         if (stat_rc != 0 && stat(outFn, &statbuf) != 0) {
3605                 // stat() failed
3606                 warning(NOCATGETS("Internal error: stat(\"%s\", ...) failed: %s\n"),
3607                         outFn, strerror(errno));
3608                 exit(1);
3609         }
3610 
3611         if ((fd = open(outFn, O_RDONLY)) < 0
3612                 && (errno != EINTR || (fd = open(outFn, O_RDONLY)) < 0)) {
3613                 // open() failed
3614                 warning(NOCATGETS("Internal error: open(\"%s\", O_RDONLY) failed: %s\n"),
3615                         outFn, strerror(errno));
3616                 exit(1);
3617         }
3618 
3619         while (!pollResultsActionTimeToFinish && stat(outFn, &statbuf) == 0) {
3620 #ifdef linux
3621                 if ((statbuf.st_mtime > file_time)
3622                    ) {
3623                         file_time = statbuf.st_mtime;
3624                         rxmGetNextResultsBlock(fd);
3625                 }
3626 #else
3627                 if ((statbuf.st_mtim.tv_sec > file_time) ||
3628                     ((statbuf.st_mtim.tv_sec == file_time) &&
3629                     (statbuf.st_mtim.tv_nsec > file_time_nsec))
3630                    ) {
3631                         file_time = statbuf.st_mtim.tv_sec;
3632                         file_time_nsec = statbuf.st_mtim.tv_nsec;
3633                         rxmGetNextResultsBlock(fd);
3634                 }
3635 #endif
3636                 us_sleep(STAT_RETRY_SLEEP_TIME);
3637         }
3638         // Check for the rest of output
3639         rxmGetNextResultsBlock(fd);
3640 
3641         (void) close(fd);
3642 }
3643 
3644 static void
3645 rxmGetNextResultsBlock(int fd)
3646 {
3647         size_t                  to_read = 8 * 1024;
3648         ssize_t                 bytes_read;
3649         ssize_t                 bytes_written;
3650         char                    results_buf[8 * 1024];
3651         sigset_t                newset;
3652         sigset_t                oldset;
3653 
3654         // Read some more from the output/results file.
3655         // Hopefully the kernel managed to prefetch the stuff.




  44 #       include <dm/Avo_MToolRsrcInfoMsg.h>
  45 #       include <dm/Avo_macro_defs.h> /* AVO_BLOCK_INTERUPTS & AVO_UNBLOCK_INTERUPTS */
  46 #       include <dmthread/Avo_ServerState.h>
  47 #       include <rw/pstream.h>
  48 #       include <rw/xdrstrea.h>
  49 #endif
  50 
  51 #include <fcntl.h>
  52 #include <mk/defs.h>
  53 #include <mksh/i18n.h>            /* get_char_semantics_value() */
  54 #include <mksh/macro.h>           /* getvar(), expand_value() */
  55 #include <mksh/misc.h>            /* getmem() */
  56 #include <poll.h>
  57 
  58 #ifdef PARALLEL
  59 #       include <rx/api.h>
  60 #endif
  61 
  62 #include <signal.h>
  63 

  64 #       include <stropts.h>

  65 
  66 #include <sys/errno.h>
  67 #include <sys/stat.h>
  68 #include <sys/types.h>
  69 #include <sys/utsname.h>  /* uname() */
  70 #include <sys/wait.h>
  71 #include <unistd.h>               /* close() */
  72 
  73 /*
  74  * Defined macros
  75  */
  76 #ifndef PARALLEL
  77 #       define LOCALHOST "localhost"
  78 #endif
  79 
  80 #define MAXRULES 100
  81 
  82 #if defined(DISTRIBUTED) || defined(MAKETOOL) /* tolik */
  83 #define SEND_MTOOL_MSG(cmds) \
  84         if (send_mtool_msgs) { \


3540 int
3541 get_job_msg_id(void)
3542 {
3543         return job_msg_id;
3544 }
3545 
3546 // Continuously poll and show the results of remotely executing a job,
3547 // i.e., output the stdout and stderr files.
3548 
3549 static int
3550 pollResults(char *outFn, char *errFn, char *hostNm)
3551 {
3552         int             child;
3553 
3554         child = fork();
3555         switch (child) {
3556         case -1:
3557                 break;
3558         case 0:
3559                 enable_interrupt((void (*) (int))SIG_DFL);



3560                 (void) sigset(SIGUSR1, Avo_PollResultsAction_Sigusr1Handler);

3561                 pollResultsAction(outFn, errFn);
3562 
3563                 exit(0);
3564                 break;
3565         default:
3566                 break;
3567         }
3568         return child;
3569 }
3570 
3571 // This is the PollResultsAction SIGUSR1 handler.
3572 
3573 static bool_t pollResultsActionTimeToFinish = FALSE;
3574 
3575 extern "C" void
3576 Avo_PollResultsAction_Sigusr1Handler(int foo)
3577 {
3578         pollResultsActionTimeToFinish = TRUE;
3579 }
3580 


3594                 us_sleep(STAT_RETRY_SLEEP_TIME);
3595         }
3596         // The previous stat() could be failed due to EINTR
3597         // So one more try is needed
3598         if (stat_rc != 0 && stat(outFn, &statbuf) != 0) {
3599                 // stat() failed
3600                 warning(NOCATGETS("Internal error: stat(\"%s\", ...) failed: %s\n"),
3601                         outFn, strerror(errno));
3602                 exit(1);
3603         }
3604 
3605         if ((fd = open(outFn, O_RDONLY)) < 0
3606                 && (errno != EINTR || (fd = open(outFn, O_RDONLY)) < 0)) {
3607                 // open() failed
3608                 warning(NOCATGETS("Internal error: open(\"%s\", O_RDONLY) failed: %s\n"),
3609                         outFn, strerror(errno));
3610                 exit(1);
3611         }
3612 
3613         while (!pollResultsActionTimeToFinish && stat(outFn, &statbuf) == 0) {







3614                 if ((statbuf.st_mtim.tv_sec > file_time) ||
3615                     ((statbuf.st_mtim.tv_sec == file_time) &&
3616                     (statbuf.st_mtim.tv_nsec > file_time_nsec))
3617                    ) {
3618                         file_time = statbuf.st_mtim.tv_sec;
3619                         file_time_nsec = statbuf.st_mtim.tv_nsec;
3620                         rxmGetNextResultsBlock(fd);
3621                 }

3622                 us_sleep(STAT_RETRY_SLEEP_TIME);
3623         }
3624         // Check for the rest of output
3625         rxmGetNextResultsBlock(fd);
3626 
3627         (void) close(fd);
3628 }
3629 
3630 static void
3631 rxmGetNextResultsBlock(int fd)
3632 {
3633         size_t                  to_read = 8 * 1024;
3634         ssize_t                 bytes_read;
3635         ssize_t                 bytes_written;
3636         char                    results_buf[8 * 1024];
3637         sigset_t                newset;
3638         sigset_t                oldset;
3639 
3640         // Read some more from the output/results file.
3641         // Hopefully the kernel managed to prefetch the stuff.