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

Diff for /src/usr.bin/mandoc/main.c between version 1.165 and 1.166

version 1.165, 2015/11/14 23:56:41 version 1.166, 2015/11/20 21:58:32
Line 121 
Line 121 
         int              show_usage;          int              show_usage;
         int              options;          int              options;
         int              use_pager;          int              use_pager;
         int              status;          int              status, signum;
         int              c;          int              c;
         pid_t            pager_pid;          pid_t            pager_pid, tc_pgid, man_pgid, pid;
   
         progname = getprogname();          progname = getprogname();
         if (strncmp(progname, "mandocdb", 8) == 0 ||          if (strncmp(progname, "mandocdb", 8) == 0 ||
Line 487 
Line 487 
         if (tag_files != NULL) {          if (tag_files != NULL) {
                 fclose(stdout);                  fclose(stdout);
                 tag_write();                  tag_write();
                 pager_pid = spawn_pager(tag_files);                  man_pgid = getpgid(0);
                   tag_files->tcpgid = man_pgid == getpid() ?
                       getpgid(getppid()) : man_pgid;
                   pager_pid = 0;
                   signum = SIGSTOP;
                 for (;;) {                  for (;;) {
                         if (waitpid(pager_pid, &status, WUNTRACED) == -1) {  
                                 if (errno == EINTR)                          /* Stop here until moved to the foreground. */
                                         continue;  
                           tc_pgid = tcgetpgrp(STDIN_FILENO);
                           if (tc_pgid != man_pgid) {
                                   if (tc_pgid == pager_pid) {
                                           (void)tcsetpgrp(STDIN_FILENO,
                                               man_pgid);
                                           if (signum == SIGTTIN)
                                                   continue;
                                   } else
                                           tag_files->tcpgid = tc_pgid;
                                   kill(0, signum);
                                   continue;
                           }
   
                           /* Once in the foreground, activate the pager. */
   
                           if (pager_pid) {
                                   (void)tcsetpgrp(STDIN_FILENO, pager_pid);
                                   kill(pager_pid, SIGCONT);
                           } else
                                   pager_pid = spawn_pager(tag_files);
   
                           /* Wait for the pager to stop or exit. */
   
                           while ((pid = waitpid(pager_pid, &status,
                               WUNTRACED)) == -1 && errno == EINTR)
                                   continue;
   
                           if (pid == -1) {
                                 warn("wait");                                  warn("wait");
                                 rc = MANDOCLEVEL_SYSERR;                                  rc = MANDOCLEVEL_SYSERR;
                                 break;                                  break;
Line 499 
Line 531 
                         if (!WIFSTOPPED(status))                          if (!WIFSTOPPED(status))
                                 break;                                  break;
   
                         (void)tcsetpgrp(STDIN_FILENO, getpgid(0));                          signum = WSTOPSIG(status);
                         kill(0, WSTOPSIG(status));  
   
                         /*  
                          * I'm now stopped.  
                          * When getting SIGCONT, continue here:  
                          */  
   
                         (void)tcsetpgrp(STDIN_FILENO, pager_pid);  
                         kill(pager_pid, SIGCONT);  
                 }                  }
                 tag_unlink();                  tag_unlink();
         }          }
Line 1001 
Line 1024 
                 break;                  break;
         default:          default:
                 (void)setpgid(pager_pid, 0);                  (void)setpgid(pager_pid, 0);
                 if (tcsetpgrp(STDIN_FILENO, pager_pid) == -1)                  (void)tcsetpgrp(STDIN_FILENO, pager_pid);
                         err((int)MANDOCLEVEL_SYSERR, "tcsetpgrp");  
                 if (pledge("stdio rpath tmppath tty proc", NULL) == -1)                  if (pledge("stdio rpath tmppath tty proc", NULL) == -1)
                         err((int)MANDOCLEVEL_SYSERR, "pledge");                          err((int)MANDOCLEVEL_SYSERR, "pledge");
                   tag_files->pager_pid = pager_pid;
                 return pager_pid;                  return pager_pid;
         }          }
   

Legend:
Removed from v.1.165  
changed lines
  Added in v.1.166