Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/mail make sure that signal handlers are always initi...



details:   https://anonhg.NetBSD.org/src/rev/2b0d1e455252
branches:  trunk
changeset: 779704:2b0d1e455252
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jun 12 19:03:26 2012 +0000

description:
make sure that signal handlers are always initialized.

diffstat:

 usr.bin/mail/cmd1.c    |   6 +++---
 usr.bin/mail/collect.c |  14 +++++++-------
 usr.bin/mail/sig.c     |  11 +++++++++--
 usr.bin/mail/sig.h     |   3 ++-
 4 files changed, 21 insertions(+), 13 deletions(-)

diffs (111 lines):

diff -r 63ea1dded849 -r 2b0d1e455252 usr.bin/mail/cmd1.c
--- a/usr.bin/mail/cmd1.c       Tue Jun 12 18:17:04 2012 +0000
+++ b/usr.bin/mail/cmd1.c       Tue Jun 12 19:03:26 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cmd1.c,v 1.32 2012/04/29 23:50:22 christos Exp $       */
+/*     $NetBSD: cmd1.c,v 1.33 2012/06/12 19:03:26 christos Exp $       */
 
 /*-
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)cmd1.c     8.2 (Berkeley) 4/20/95";
 #else
-__RCSID("$NetBSD: cmd1.c,v 1.32 2012/04/29 23:50:22 christos Exp $");
+__RCSID("$NetBSD: cmd1.c,v 1.33 2012/06/12 19:03:26 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -448,7 +448,7 @@
 {
        char *cmd;
        FILE *volatile obuf;            /* void longjmp clobbering */
-       sig_t volatile oldsigpipe;      /* XXX - is volatile needed? */
+       sig_t volatile oldsigpipe = sig_current(SIGPIPE);
 
        cmd = v;
        if (dot == NULL) {
diff -r 63ea1dded849 -r 2b0d1e455252 usr.bin/mail/collect.c
--- a/usr.bin/mail/collect.c    Tue Jun 12 18:17:04 2012 +0000
+++ b/usr.bin/mail/collect.c    Tue Jun 12 19:03:26 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: collect.c,v 1.45 2012/04/29 23:50:22 christos Exp $    */
+/*     $NetBSD: collect.c,v 1.46 2012/06/12 19:03:26 christos Exp $    */
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)collect.c  8.2 (Berkeley) 4/19/94";
 #else
-__RCSID("$NetBSD: collect.c,v 1.45 2012/04/29 23:50:22 christos Exp $");
+__RCSID("$NetBSD: collect.c,v 1.46 2012/06/12 19:03:26 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -355,11 +355,11 @@
 PUBLIC FILE *
 collect(struct header *hp, int printheaders)
 {
-       volatile sig_t old_sigint;
-       volatile sig_t old_sighup;
-       volatile sig_t old_sigtstp;
-       volatile sig_t old_sigttin;
-       volatile sig_t old_sigttou;
+       sig_t volatile old_sigint = sig_current(SIGINT);
+       sig_t volatile old_sighup = sig_current(SIGHUP);
+       sig_t volatile old_sigtstp = sig_current(SIGTSTP);
+       sig_t volatile old_sigttin = sig_current(SIGTTIN);
+       sig_t volatile old_sigttou = sig_current(SIGTTOU);
        FILE *fbuf;
        int lc, cc;
        int c, fd, t;
diff -r 63ea1dded849 -r 2b0d1e455252 usr.bin/mail/sig.c
--- a/usr.bin/mail/sig.c        Tue Jun 12 18:17:04 2012 +0000
+++ b/usr.bin/mail/sig.c        Tue Jun 12 19:03:26 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig.c,v 1.2 2011/01/10 17:14:38 dyoung Exp $   */
+/*     $NetBSD: sig.c,v 1.3 2012/06/12 19:03:26 christos Exp $ */
 
 /*
  * Copyright (c) 1980, 1993
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: sig.c,v 1.2 2011/01/10 17:14:38 dyoung Exp $");
+__RCSID("$NetBSD: sig.c,v 1.3 2012/06/12 19:03:26 christos Exp $");
 #endif /* not lint */
 
 #include <assert.h>
@@ -162,6 +162,13 @@
 }
 
 PUBLIC sig_t
+sig_current(int signo)
+{
+       assert(signo > 0 && signo < NSIG);
+       return sigarray[signo];
+}
+
+PUBLIC sig_t
 sig_signal(int signo, sig_t handler)
 {
        sig_t old_handler;
diff -r 63ea1dded849 -r 2b0d1e455252 usr.bin/mail/sig.h
--- a/usr.bin/mail/sig.h        Tue Jun 12 18:17:04 2012 +0000
+++ b/usr.bin/mail/sig.h        Tue Jun 12 19:03:26 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sig.h,v 1.1 2009/04/10 13:08:25 christos Exp $ */
+/*     $NetBSD: sig.h,v 1.2 2012/06/12 19:03:26 christos Exp $ */
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
 void sig_check(void);
 void sig_setup(void);
 sig_t sig_signal(int, sig_t);
+sig_t sig_current(int);
 
 #endif /* __SIG_H__ */
 



Home | Main Index | Thread Index | Old Index