summaryrefslogtreecommitdiff
path: root/usr.bin/mail/collect.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-11 12:54:26 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-06-11 12:54:26 +0000
commit1c5940ab5503bf389f03195f3d01a93353919abb (patch)
treea1e9691c11b7f36906f0943dc7d8464a56b98adc /usr.bin/mail/collect.c
parent5f733ec731243d90e1e65f27ce29e683e7a253a6 (diff)
from christos;
- Fix PR/105: Implement dot locking protocol and check return value of flock. - Fix PR/2247: Don't call unknown users "ubluit". Issue an error message. - Fix/add prototypes. - Fix warnings. - Use POSIX signal mask calls.
Diffstat (limited to 'usr.bin/mail/collect.c')
-rw-r--r--usr.bin/mail/collect.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c
index 151c64ab159..c17e46ceef5 100644
--- a/usr.bin/mail/collect.c
+++ b/usr.bin/mail/collect.c
@@ -1,3 +1,6 @@
+/* $OpenBSD: collect.c,v 1.2 1996/06/11 12:53:35 deraadt Exp $ */
+/* $NetBSD: collect.c,v 1.6 1996/06/08 19:48:16 christos Exp $ */
+
/*
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
@@ -32,8 +35,11 @@
*/
#ifndef lint
-static char sccsid[] = "from: @(#)collect.c 8.2 (Berkeley) 4/19/94";
-static char rcsid[] = "$Id: collect.c,v 1.1 1995/10/18 08:45:38 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
+#else
+static char rcsid[] = "$OpenBSD: collect.c,v 1.2 1996/06/11 12:53:35 deraadt Exp $";
+#endif
#endif /* not lint */
/*
@@ -80,15 +86,23 @@ collect(hp, printheaders)
char linebuf[LINESIZE], *cp;
extern char *tempMail;
char getsub;
- int omask;
- void collint(), collhup(), collstop();
+ sigset_t oset, nset;
+#if __GNUC__
+ /* Avoid longjmp clobbering */
+ (void) &escape;
+ (void) &eofcount;
+ (void) &getsub;
+#endif
collf = NULL;
/*
* 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));
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGHUP);
+ sigprocmask(SIG_BLOCK, &nset, &oset);
if ((saveint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
signal(SIGINT, collint);
if ((savehup = signal(SIGHUP, SIG_IGN)) != SIG_IGN)
@@ -100,7 +114,7 @@ collect(hp, printheaders)
rm(tempMail);
goto err;
}
- sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP)));
+ sigprocmask(SIG_SETMASK, &oset, NULL);
noreset++;
if ((collf = Fopen(tempMail, "w+")) == NULL) {
@@ -191,7 +205,7 @@ cont:
/*
* Dump core.
*/
- core();
+ core(NULL);
break;
case '!':
/*
@@ -375,13 +389,16 @@ out:
if (collf != NULL)
rewind(collf);
noreset--;
- sigblock(sigmask(SIGINT) | sigmask(SIGHUP));
+ sigemptyset(&nset);
+ sigaddset(&nset, SIGINT);
+ sigaddset(&nset, SIGHUP);
+ sigprocmask(SIG_BLOCK, &nset, &oset);
signal(SIGINT, saveint);
signal(SIGHUP, savehup);
signal(SIGTSTP, savetstp);
signal(SIGTTOU, savettou);
signal(SIGTTIN, savettin);
- sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &oset, NULL);
return collf;
}
@@ -561,10 +578,13 @@ collstop(s)
int s;
{
sig_t old_action = signal(s, SIG_DFL);
+ sigset_t nset;
- sigsetmask(sigblock(0) & ~sigmask(s));
+ sigemptyset(&nset);
+ sigaddset(&nset, s);
+ sigprocmask(SIG_UNBLOCK, &nset, NULL);
kill(0, s);
- sigblock(sigmask(s));
+ sigprocmask(SIG_BLOCK, &nset, NULL);
signal(s, old_action);
if (colljmp_p) {
colljmp_p = 0;