[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.164 and 1.165

version 1.164, 2015/11/07 17:58:52 version 1.165, 2015/11/14 23:56:41
Line 24 
Line 24 
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  #include <ctype.h>
 #include <err.h>  #include <err.h>
   #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <glob.h>  #include <glob.h>
 #include <signal.h>  #include <signal.h>
Line 120 
Line 121 
         int              show_usage;          int              show_usage;
         int              options;          int              options;
         int              use_pager;          int              use_pager;
           int              status;
         int              c;          int              c;
           pid_t            pager_pid;
   
         progname = getprogname();          progname = getprogname();
         if (strncmp(progname, "mandocdb", 8) == 0 ||          if (strncmp(progname, "mandocdb", 8) == 0 ||
             strncmp(progname, "makewhatis", 10) == 0)              strncmp(progname, "makewhatis", 10) == 0)
                 return mandocdb(argc, argv);                  return mandocdb(argc, argv);
   
         if (pledge("stdio rpath tmppath proc exec flock", NULL) == -1)          if (pledge("stdio rpath tmppath tty proc exec flock", NULL) == -1)
                 err((int)MANDOCLEVEL_SYSERR, "pledge");                  err((int)MANDOCLEVEL_SYSERR, "pledge");
   
         /* Search options. */          /* Search options. */
Line 387 
Line 390 
   
         /* mandoc(1) */          /* mandoc(1) */
   
         if (pledge(use_pager ? "stdio rpath tmppath proc exec" :          if (pledge(use_pager ? "stdio rpath tmppath tty proc exec" :
             "stdio rpath", NULL) == -1)              "stdio rpath", NULL) == -1)
                 err((int)MANDOCLEVEL_SYSERR, "pledge");                  err((int)MANDOCLEVEL_SYSERR, "pledge");
   
Line 484 
Line 487 
         if (tag_files != NULL) {          if (tag_files != NULL) {
                 fclose(stdout);                  fclose(stdout);
                 tag_write();                  tag_write();
                 waitpid(spawn_pager(tag_files), NULL, 0);                  pager_pid = spawn_pager(tag_files);
                   for (;;) {
                           if (waitpid(pager_pid, &status, WUNTRACED) == -1) {
                                   if (errno == EINTR)
                                           continue;
                                   warn("wait");
                                   rc = MANDOCLEVEL_SYSERR;
                                   break;
                           }
                           if (!WIFSTOPPED(status))
                                   break;
   
                           (void)tcsetpgrp(STDIN_FILENO, getpgid(0));
                           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 971 
Line 996 
         case -1:          case -1:
                 err((int)MANDOCLEVEL_SYSERR, "fork");                  err((int)MANDOCLEVEL_SYSERR, "fork");
         case 0:          case 0:
                   /* Set pgrp in both parent and child to avoid racing exec. */
                   (void)setpgid(0, 0);
                 break;                  break;
         default:          default:
                 if (pledge("stdio rpath tmppath", NULL) == -1)                  (void)setpgid(pager_pid, 0);
                   if (tcsetpgrp(STDIN_FILENO, pager_pid) == -1)
                           err((int)MANDOCLEVEL_SYSERR, "tcsetpgrp");
                   if (pledge("stdio rpath tmppath tty proc", NULL) == -1)
                         err((int)MANDOCLEVEL_SYSERR, "pledge");                          err((int)MANDOCLEVEL_SYSERR, "pledge");
                 return pager_pid;                  return pager_pid;
         }          }

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