Ticket #636: debathena-nmh.patch
File debathena-nmh.patch, 3.1 KB (added by broder, 14 years ago) |
---|
-
uip/mhshowsbr.c
old new 47 47 int nomore = 0; 48 48 char *formsw = NULL; 49 49 50 pid_t xpid = 0 ;50 pid_t xpid = 0, m_pid = 0; 51 51 52 52 static sigjmp_buf intrenv; 53 53 … … 90 90 static int show_partial (CT, int, int); 91 91 static int show_external (CT, int, int); 92 92 static RETSIGTYPE intrser (int); 93 static void m_popen (char *); 94 static void m_pclose (void); 93 95 94 96 95 97 /* … … 143 145 * the viewer (e.g., lynx) are going to be accessible */ 144 146 umask (ct->c_umask & ~(0100)); 145 147 148 if (!nomore && isatty (fileno (stdout))) 149 m_popen (progsw ? progsw : moreproc); 150 146 151 /* 147 152 * If you have a format file, then display 148 153 * the message headers. … … 170 175 sigaddset (&set, SIGTERM); 171 176 SIGPROCMASK (SIG_BLOCK, &set, &oset); 172 177 178 m_pclose (); 179 173 180 while (wait (&status) != NOTOK) { 174 181 #ifdef WAITINT 175 182 pidcheck (status); … … 203 210 vec[vecp++] = "-form"; 204 211 vec[vecp++] = form; 205 212 vec[vecp++] = "-nobody"; 213 vec[vecp++] = "-nomoreproc"; 206 214 vec[vecp++] = ct->c_file; 207 208 /*209 * If we've specified -(no)moreproc,210 * then just pass that along.211 */212 if (nomore) {213 vec[vecp++] = "-nomoreproc";214 } else if (progsw) {215 vec[vecp++] = "-moreproc";216 vec[vecp++] = progsw;217 }218 215 vec[vecp] = NULL; 219 216 220 217 fflush (stdout); … … 546 543 xpid = 0; 547 544 } 548 545 546 if (xstdin && m_pid) 547 m_pclose (); 548 549 549 if (xlist) { 550 550 char prompt[BUFSIZ]; 551 551 … … 647 647 * if it is not a text part of a multipart/alternative 648 648 */ 649 649 if (!alternate || ct->c_subtype == TEXT_PLAIN) { 650 snprintf (buffer, sizeof(buffer), "%%p%s '%%F'", progsw ? progsw : 651 moreproc && *moreproc ? moreproc : "more"); 650 snprintf (buffer, sizeof(buffer), "%%ecat '%%f'"); 652 651 cp = (ct->c_showproc = add (buffer, NULL)); 653 652 return show_content_aux (ct, serial, alternate, cp, NULL); 654 653 } … … 1121 1120 putchar ('\n'); 1122 1121 siglongjmp (intrenv, DONE); 1123 1122 } 1123 1124 static int sd = NOTOK; 1125 1126 static void 1127 m_popen (char *name) 1128 { 1129 int pd[2]; 1130 1131 if ((sd = dup (fileno (stdout))) == NOTOK) 1132 adios ("standard output", "unable to dup()"); 1133 1134 if (pipe (pd) == NOTOK) 1135 adios ("pipe", "unable to"); 1136 1137 switch (m_pid = vfork ()) { 1138 case NOTOK: 1139 adios ("fork", "unable to"); 1140 1141 case OK: 1142 SIGNAL (SIGINT, SIG_DFL); 1143 SIGNAL (SIGQUIT, SIG_DFL); 1144 1145 close (pd[1]); 1146 if (pd[0] != fileno (stdin)) { 1147 dup2 (pd[0], fileno (stdin)); 1148 close (pd[0]); 1149 } 1150 execlp (name, r1bindex (name, '/'), NULL); 1151 fprintf (stderr, "unable to exec "); 1152 perror (name); 1153 _exit (-1); 1154 1155 default: 1156 close (pd[0]); 1157 if (pd[1] != fileno (stdout)) { 1158 dup2 (pd[1], fileno (stdout)); 1159 close (pd[1]); 1160 } 1161 } 1162 } 1163 1164 1165 void 1166 m_pclose (void) 1167 { 1168 if (!m_pid) 1169 return; 1170 1171 if (sd != NOTOK) { 1172 if (dup2 (sd, fileno (stdout)) == NOTOK) 1173 adios ("standard output", "unable to dup2()"); 1174 1175 clearerr (stdout); 1176 close (sd); 1177 sd = NOTOK; 1178 } 1179 else 1180 fclose (stdout); 1181 1182 pidwait (m_pid, OK); 1183 m_pid = 0; 1184 }