diff -cr popmail/cmd1.c popmail.sigproc/cmd1.c *** popmail/cmd1.c Thu Oct 15 02:44:49 1998 --- popmail.sigproc/cmd1.c Sun Feb 22 02:25:42 1998 *************** *** 450,455 **** } if ((cmd = value("LISTER")) == NOSTR) cmd = "ls"; ! (void) run_command(cmd, 0, -1, -1, dirname, NOSTR, NOSTR); return 0; } --- 450,455 ---- } if ((cmd = value("LISTER")) == NOSTR) cmd = "ls"; ! (void) run_command(cmd, -1, -1, dirname, NOSTR, NOSTR); return 0; } diff -cr popmail/cmd3.c popmail.sigproc/cmd3.c *** popmail/cmd3.c Thu Oct 15 02:45:12 1998 --- popmail.sigproc/cmd3.c Sun Feb 22 02:25:51 1998 *************** *** 61,67 **** return 1; if ((shell = value("SHELL")) == NOSTR) shell = _PATH_CSHELL; ! (void) run_command(shell, 0, -1, -1, "-c", cmd, NOSTR); (void) Signal(SIGINT, sigint); printf("!\n"); return 0; --- 61,67 ---- return 1; if ((shell = value("SHELL")) == NOSTR) shell = _PATH_CSHELL; ! (void) run_command(shell, -1, -1, "-c", cmd, NOSTR); (void) Signal(SIGINT, sigint); printf("!\n"); return 0; *************** *** 80,86 **** if ((shell = value("SHELL")) == NOSTR) shell = _PATH_CSHELL; ! (void) run_command(shell, 0, -1, -1, NOSTR, NOSTR, NOSTR); (void) Signal(SIGINT, sigint); putchar('\n'); return 0; --- 80,86 ---- if ((shell = value("SHELL")) == NOSTR) shell = _PATH_CSHELL; ! (void) run_command(shell, -1, -1, NOSTR, NOSTR, NOSTR); (void) Signal(SIGINT, sigint); putchar('\n'); return 0; diff -cr popmail/collect.c popmail.sigproc/collect.c *** popmail/collect.c Thu Oct 15 03:07:39 1998 --- popmail.sigproc/collect.c Sun Feb 22 02:25:59 1998 *************** *** 79,85 **** char linebuf[LINESIZE], *cp; extern char tempMail[]; char getsub; ! int omask; collf = NULL; /* --- 79,85 ---- char linebuf[LINESIZE], *cp; extern char tempMail[]; char getsub; ! sigset_t omask, nmask; collf = NULL; /* *************** *** 86,92 **** * Start catching signals from here, but we're still die on interrupts * until we're in the main loop. */ ! omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); if ((saveint = Signal(SIGINT, SIG_IGN)) != SIG_IGN) Signal(SIGINT, collint); if ((savehup = Signal(SIGHUP, SIG_IGN)) != SIG_IGN) --- 86,95 ---- * Start catching signals from here, but we're still die on interrupts * until we're in the main loop. */ ! sigemptyset(&nmask); ! sigaddset(&nmask, SIGINT); ! sigaddset(&nmask, SIGHUP); ! sigprocmask(SIG_BLOCK, &nmask, &omask); if ((saveint = Signal(SIGINT, SIG_IGN)) != SIG_IGN) Signal(SIGINT, collint); if ((savehup = Signal(SIGHUP, SIG_IGN)) != SIG_IGN) *************** *** 98,104 **** rm(tempMail); goto err; } ! sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP))); noreset++; if ((collf = Fopen(tempMail, "w+")) == NULL) { --- 101,110 ---- rm(tempMail); goto err; } ! nmask = omask; ! sigdelset(&nmask, SIGINT); ! sigdelset(&nmask, SIGHUP); ! sigprocmask(SIG_SETMASK, &nmask, NULL); noreset++; if ((collf = Fopen(tempMail, "w+")) == NULL) { *************** *** 381,393 **** if (collf != NULL) rewind(collf); noreset--; ! sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); Signal(SIGINT, saveint); Signal(SIGHUP, savehup); Signal(SIGTSTP, savetstp); Signal(SIGTTOU, savettou); Signal(SIGTTIN, savettin); ! sigsetmask(omask); return collf; } --- 387,402 ---- if (collf != NULL) rewind(collf); noreset--; ! sigemptyset(&nmask); ! sigaddset(&nmask, SIGINT); ! sigaddset(&nmask, SIGHUP); ! sigprocmask(SIG_BLOCK, &nmask, NULL); Signal(SIGINT, saveint); Signal(SIGHUP, savehup); Signal(SIGTSTP, savetstp); Signal(SIGTTOU, savettou); Signal(SIGTTIN, savettin); ! sigprocmask(SIG_SETMASK, &omask, NULL); return collf; } *************** *** 487,493 **** if ((shell = value("SHELL")) == NOSTR) shell = _PATH_CSHELL; if (run_command(shell, ! 0, fileno(fp), fileno(nf), "-c", cmd, NOSTR) < 0) { (void) Fclose(nf); goto out; } --- 496,502 ---- if ((shell = value("SHELL")) == NOSTR) shell = _PATH_CSHELL; if (run_command(shell, ! fileno(fp), fileno(nf), "-c", cmd, NOSTR) < 0) { (void) Fclose(nf); goto out; } *************** *** 567,576 **** int s; { sig_t old_action = Signal(s, SIG_DFL); ! sigsetmask(sigblock(0) & ~sigmask(s)); kill(0, s); ! sigblock(sigmask(s)); Signal(s, old_action); if (colljmp_p) { fpurge(stdin); --- 576,590 ---- int s; { sig_t old_action = Signal(s, SIG_DFL); + sigset_t omask, nmask; ! sigemptyset(&nmask); ! sigprocmask(SIG_BLOCK, &nmask, &omask); ! sigdelset(&omask, s); ! sigprocmask(SIG_SETMASK, &omask, NULL); kill(0, s); ! sigaddset(&nmask, s); ! sigprocmask(SIG_BLOCK, &nmask, NULL); Signal(s, old_action); if (colljmp_p) { fpurge(stdin); diff -cr popmail/configure.in popmail.sigproc/configure.in *** popmail/configure.in Thu Oct 15 03:18:45 1998 --- popmail.sigproc/configure.in Thu Oct 15 02:36:48 1998 *************** *** 7,13 **** AC_TIME_WITH_SYS_TIME AC_HAVE_HEADERS(unistd.h termios.h sgtty.h paths.h) AC_HAVE_FUNCS(sigaction sigsetjmp) ! AC_REPLACE_FUNCS(flock mkstemp strstr strerror) AC_VFORK AC_SUBST(SOCKET_LIBS) --- 7,13 ---- AC_TIME_WITH_SYS_TIME AC_HAVE_HEADERS(unistd.h termios.h sgtty.h paths.h) AC_HAVE_FUNCS(sigaction sigsetjmp) ! AC_REPLACE_FUNCS(flock mkstemp sigprocmask strstr strerror) AC_VFORK AC_SUBST(SOCKET_LIBS) diff -cr popmail/edit.c popmail.sigproc/edit.c *** popmail/edit.c Thu Oct 15 02:45:30 1998 --- popmail.sigproc/edit.c Sun Feb 22 02:26:06 1998 *************** *** 186,192 **** nf = NULL; if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NOSTR) edit = type == 'e' ? _PATH_EX : _PATH_VI; ! run_command(edit, 0, -1, -1, tempEdit, NOSTR, NOSTR); /* * If in read only mode or file unchanged, just remove the editor * temporary and return. --- 186,192 ---- nf = NULL; if ((edit = value(type == 'e' ? "EDITOR" : "VISUAL")) == NOSTR) edit = type == 'e' ? _PATH_EX : _PATH_VI; ! run_command(edit, -1, -1, tempEdit, NOSTR, NOSTR); /* * If in read only mode or file unchanged, just remove the editor * temporary and return. diff -cr popmail/extern.h popmail.sigproc/extern.h *** popmail/extern.h Thu Oct 15 03:04:23 1998 --- popmail.sigproc/extern.h Sun Jun 28 00:08:56 1998 *************** *** 186,192 **** void parse __P((char [], struct headline *, char [])); int pcmdlist __P((void)); int pdot __P((void)); ! void prepare_child __P((int, int, int)); int preserve __P((int *)); void prettyprint __P((struct name *)); void printgroup __P((char [])); --- 186,192 ---- void parse __P((char [], struct headline *, char [])); int pcmdlist __P((void)); int pdot __P((void)); ! void prepare_child __P((sigset_t *, int, int)); int preserve __P((int *)); void prettyprint __P((struct name *)); void printgroup __P((char [])); *************** *** 205,211 **** int retfield __P((char *[])); int rexit __P((int)); int rm __P((char *)); ! int run_command __P((char *, int, int, int, char *, char *, char *)); int save __P((char [])); int save1 __P((char [], int, char *, struct ignoretab *)); int saveauthor __P((int *)); --- 205,211 ---- int retfield __P((char *[])); int rexit __P((int)); int rm __P((char *)); ! int run_command __P((char *, int, int, char *, char *, char *)); int save __P((char [])); int save1 __P((char [], int, char *, struct ignoretab *)); int saveauthor __P((int *)); *************** *** 232,238 **** int source __P((char **)); void spreserve __P((void)); void sreset __P((void)); ! int start_command __P((char *, int, int, int, char *, char *, char *)); void statusput __P((struct message *, FILE *, char *)); void stop __P((int)); int stouch __P((int [])); --- 232,238 ---- int source __P((char **)); void spreserve __P((void)); void sreset __P((void)); ! int start_command __P((char *, sigset_t *, int, int, char *, char *, char *)); void statusput __P((struct message *, FILE *, char *)); void stop __P((int)); int stouch __P((int [])); diff -cr popmail/fio.c popmail.sigproc/fio.c *** popmail/fio.c Thu Oct 15 02:33:31 1998 --- popmail.sigproc/fio.c Wed Feb 25 09:56:10 1998 *************** *** 254,260 **** } static int sigdepth; /* depth of holdsigs() */ ! static int omask; /* * Hold signals SIGHUP, SIGINT, and SIGQUIT. */ --- 254,260 ---- } static int sigdepth; /* depth of holdsigs() */ ! static sigset_t omask; /* * Hold signals SIGHUP, SIGINT, and SIGQUIT. */ *************** *** 261,269 **** void holdsigs() { ! ! if (sigdepth++ == 0) ! omask = sigblock(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT)); } /* --- 261,274 ---- void holdsigs() { ! sigset_t nmask; ! if (sigdepth++ == 0) { ! sigemptyset(&nmask); ! sigaddset(&nmask, SIGHUP); ! sigaddset(&nmask, SIGINT); ! sigaddset(&nmask, SIGQUIT); ! sigprocmask(SIG_BLOCK, &nmask, &omask); ! } } /* *************** *** 274,280 **** { if (--sigdepth == 0) ! sigsetmask(omask); } /* --- 279,285 ---- { if (--sigdepth == 0) ! sigprocmask(SIG_SETMASK, &omask, NULL); } /* diff -cr popmail/lex.c popmail.sigproc/lex.c *** popmail/lex.c Thu Oct 15 02:33:47 1998 --- popmail.sigproc/lex.c Sun Feb 22 00:10:40 1998 *************** *** 536,545 **** int s; { sig_t old_action = Signal(s, SIG_DFL); ! sigsetmask(sigblock(0) & ~sigmask(s)); kill(0, s); ! sigblock(sigmask(s)); Signal(s, old_action); if (reset_on_stop) { reset_on_stop = 0; --- 536,550 ---- int s; { sig_t old_action = Signal(s, SIG_DFL); + sigset_t omask, nmask; ! sigemptyset(&nmask); ! sigprocmask(SIG_BLOCK, &nmask, &omask); ! sigdelset(&omask, s); ! sigprocmask(SIG_SETMASK, &omask, NULL); kill(0, s); ! sigaddset(&nmask, s); ! sigprocmask(SIG_BLOCK, &nmask, NULL); Signal(s, old_action); if (reset_on_stop) { reset_on_stop = 0; diff -cr popmail/names.c popmail.sigproc/names.c *** popmail/names.c Thu Oct 15 02:34:00 1998 --- popmail.sigproc/names.c Sun Feb 22 02:12:07 1998 *************** *** 223,228 **** --- 223,229 ---- char *date, *fname; FILE *fout, *fin; int ispipe; + sigset_t mask; extern char tempEdit[]; top = names; *************** *** 291,298 **** */ if ((shell = value("SHELL")) == NOSTR) shell = _PATH_CSHELL; ! pid = start_command(shell, sigmask(SIGHUP)| ! sigmask(SIGINT)|sigmask(SIGQUIT), image, -1, "-c", fname, NOSTR); if (pid < 0) { senderr++; --- 292,302 ---- */ if ((shell = value("SHELL")) == NOSTR) shell = _PATH_CSHELL; ! sigemptyset(&mask); ! sigaddset(&mask, SIGHUP); ! sigaddset(&mask, SIGINT); ! sigaddset(&mask, SIGQUIT); ! pid = start_command(shell, &mask, image, -1, "-c", fname, NOSTR); if (pid < 0) { senderr++; diff -cr popmail/popen.c popmail.sigproc/popen.c *** popmail/popen.c Thu Oct 15 02:34:19 1998 --- popmail.sigproc/popen.c Sun Feb 22 02:28:03 1998 *************** *** 136,149 **** FILE *ptr; { int i; ! int omask; i = file_pid(ptr); unregister_file(ptr); (void) fclose(ptr); ! omask = sigblock(sigmask(SIGINT)|sigmask(SIGHUP)); i = wait_child(i); ! sigsetmask(omask); return i; } --- 136,152 ---- FILE *ptr; { int i; ! sigset_t omask, nmask; i = file_pid(ptr); unregister_file(ptr); (void) fclose(ptr); ! sigemptyset(&nmask); ! sigaddset(&nmask, SIGINT); ! sigaddset(&nmask, SIGHUP); ! sigprocmask(SIG_BLOCK, &nmask, &omask); i = wait_child(i); ! sigprocmask(SIG_SETMASK, &omask, NULL); return i; } *************** *** 210,223 **** */ /*VARARGS4*/ int ! run_command(cmd, mask, infd, outfd, a0, a1, a2) char *cmd; ! int mask, infd, outfd; char *a0, *a1, *a2; { int pid; ! if ((pid = start_command(cmd, mask, infd, outfd, a0, a1, a2)) < 0) return -1; if (wait_child(pid) < 0) { printf("Error: %s returned an error status.\n", cmd); --- 213,226 ---- */ /*VARARGS4*/ int ! run_command(cmd, infd, outfd, a0, a1, a2) char *cmd; ! int infd, outfd; char *a0, *a1, *a2; { int pid; ! if ((pid = start_command(cmd, 0, infd, outfd, a0, a1, a2)) < 0) return -1; if (wait_child(pid) < 0) { printf("Error: %s returned an error status.\n", cmd); *************** *** 230,236 **** int start_command(cmd, mask, infd, outfd, a0, a1, a2) char *cmd; ! int mask, infd, outfd; char *a0, *a1, *a2; { int pid; --- 233,240 ---- int start_command(cmd, mask, infd, outfd, a0, a1, a2) char *cmd; ! sigset_t *mask; ! int infd, outfd; char *a0, *a1, *a2; { int pid; *************** *** 257,265 **** void prepare_child(mask, infd, outfd) ! int mask, infd, outfd; { int i; /* * All file descriptors other than 0, 1, and 2 are supposed to be --- 261,271 ---- void prepare_child(mask, infd, outfd) ! sigset_t *mask; ! int infd, outfd; { int i; + sigset_t empty; /* * All file descriptors other than 0, 1, and 2 are supposed to be *************** *** 269,280 **** dup2(infd, 0); if (outfd >= 0) dup2(outfd, 1); ! for (i = 1; i <= NSIG; i++) ! if (mask & sigmask(i)) ! (void) Signal(i, SIG_IGN); ! if ((mask & sigmask(SIGINT)) == 0) ! (void) Signal(SIGINT, SIG_DFL); ! (void) sigsetmask(0); } static struct child * --- 275,289 ---- dup2(infd, 0); if (outfd >= 0) dup2(outfd, 1); ! if (mask != NULL) { ! for (i = 1; i <= NSIG; i++) ! if (sigismember(mask, i)) ! (void) Signal(i, SIG_IGN); ! if (sigismember(mask, SIGINT)) ! (void) Signal(SIGINT, SIG_DFL); ! } ! sigemptyset(&empty); ! sigprocmask(SIG_SETMASK, &empty, NULL); } static struct child * *************** *** 336,349 **** wait_child(pid) int pid; { ! int mask = sigblock(sigmask(SIGCHLD)); ! register struct child *cp = findchild(pid); while (!cp->done) ! sigpause(mask); wait_status = cp->status; delchild(cp); ! sigsetmask(mask); return WEXITSTATUS(wait_status) ? -1 : 0; } --- 345,361 ---- wait_child(pid) int pid; { ! sigset_t omask, nmask; ! struct child *cp = findchild(pid); + sigemptyset(&nmask); + sigaddset(&nmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &nmask, &omask); while (!cp->done) ! sigsuspend(&omask); wait_status = cp->status; delchild(cp); ! sigprocmask(SIG_SETMASK, &omask, NULL); return WEXITSTATUS(wait_status) ? -1 : 0; } *************** *** 354,365 **** free_child(pid) int pid; { ! int mask = sigblock(sigmask(SIGCHLD)); ! register struct child *cp = findchild(pid); if (cp->done) delchild(cp); else cp->free = 1; ! sigsetmask(mask); } --- 366,380 ---- free_child(pid) int pid; { ! sigset_t omask, nmask; ! struct child *cp = findchild(pid); + sigemptyset(&nmask); + sigaddset(&nmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &nmask, &omask); if (cp->done) delchild(cp); else cp->free = 1; ! sigprocmask(SIG_SETMASK, &omask, NULL); } diff -cr popmail/rcv.h popmail.sigproc/rcv.h *** popmail/rcv.h Sun Oct 11 04:39:43 1998 --- popmail.sigproc/rcv.h Thu Oct 15 02:37:01 1998 *************** *** 80,85 **** --- 80,89 ---- #endif #endif + #if !HAVE_SIGPROCMASK + #include "sigprocmask.h" + #endif + #if !HAVE_SIG_T typedef void (*sig_t)(); #endif diff -cr popmail/send.c popmail.sigproc/send.c *** popmail/send.c Thu Oct 15 02:34:54 1998 --- popmail.sigproc/send.c Sun Feb 22 02:13:18 1998 *************** *** 302,307 **** --- 302,308 ---- char **namelist; struct name *to; FILE *mtf; + sigset_t mask; /* * Collect user's mail from standard input. *************** *** 371,379 **** goto out; } if (pid == 0) { ! prepare_child(sigmask(SIGHUP)|sigmask(SIGINT)|sigmask(SIGQUIT)| ! sigmask(SIGTSTP)|sigmask(SIGTTIN)|sigmask(SIGTTOU), ! fileno(mtf), -1); if ((cp = value("sendmail")) != NOSTR) cp = expand(cp); else --- 372,385 ---- goto out; } if (pid == 0) { ! sigemptyset(&mask); ! sigaddset(&mask, SIGHUP); ! sigaddset(&mask, SIGINT); ! sigaddset(&mask, SIGQUIT); ! sigaddset(&mask, SIGTSTP); ! sigaddset(&mask, SIGTTIN); ! sigaddset(&mask, SIGTTOU); ! prepare_child(&mask, fileno(mtf), -1); if ((cp = value("sendmail")) != NOSTR) cp = expand(cp); else diff -cr popmail/tty.c popmail.sigproc/tty.c *** popmail/tty.c Thu Oct 15 02:37:49 1998 --- popmail.sigproc/tty.c Thu Oct 15 02:36:52 1998 *************** *** 284,293 **** int s; { sig_t old_action = Signal(s, SIG_DFL); ! sigsetmask(sigblock(0) & ~sigmask(s)); kill(0, s); ! sigblock(sigmask(s)); Signal(s, old_action); fpurge(stdin); longjmp(rewrite, 1); --- 286,300 ---- int s; { sig_t old_action = Signal(s, SIG_DFL); + sigset_t omask, nmask; ! sigemptyset(&nmask); ! sigprocmask(SIG_BLOCK, &nmask, &omask); ! sigdelset(&omask, s); ! sigprocmask(SIG_SETMASK, &omask, NULL); kill(0, s); ! sigaddset(&nmask, s); ! sigprocmask(SIG_BLOCK, &nmask, NULL); Signal(s, old_action); fpurge(stdin); longjmp(rewrite, 1);