Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/ftp fetch_url: improve signal handler restoration



details:   https://anonhg.NetBSD.org/src/rev/b8028bb83a98
branches:  trunk
changeset: 973743:b8028bb83a98
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sat Jul 11 00:29:38 2020 +0000

description:
fetch_url: improve signal handler restoration

Use SIG_ERR not NULL as the indicator that a signal handler
hasn't been changed, so that SIG_DFL (equivalent to NULL)
will be restored.

Fix restoration of SIGQUIT; use the old handler not SIGPIPE's.

diffstat:

 usr.bin/ftp/fetch.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (59 lines):

diff -r 3354935876f2 -r b8028bb83a98 usr.bin/ftp/fetch.c
--- a/usr.bin/ftp/fetch.c       Fri Jul 10 20:34:24 2020 +0000
+++ b/usr.bin/ftp/fetch.c       Sat Jul 11 00:29:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fetch.c,v 1.231 2019/04/04 00:36:09 christos Exp $     */
+/*     $NetBSD: fetch.c,v 1.232 2020/07/11 00:29:38 lukem Exp $        */
 
 /*-
  * Copyright (c) 1997-2015 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.231 2019/04/04 00:36:09 christos Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.232 2020/07/11 00:29:38 lukem Exp $");
 #endif /* not lint */
 
 /*
@@ -1295,7 +1295,7 @@
 
        DPRINTF("%s: `%s' proxyenv `%s'\n", __func__, url, STRorNULL(penv));
 
-       oldquit = oldalrm = oldint = oldpipe = NULL;
+       oldquit = oldalrm = oldint = oldpipe = SIG_ERR;
        closefunc = NULL;
        fin = NULL;
        fout = NULL;
@@ -1572,9 +1572,9 @@
 
        bytes = 0;
        hashbytes = mark;
-       if (oldalrm) {
+       if (oldalrm != SIG_ERR) {
                (void)xsignal(SIGALRM, oldalrm);
-               oldalrm = NULL;
+               oldalrm = SIG_ERR;
        }
        progressmeter(-1);
 
@@ -1736,14 +1736,14 @@
        warnx("Improper response from `%s:%s'", ui.host, ui.port);
 
  cleanup_fetch_url:
-       if (oldint)
+       if (oldint != SIG_ERR)
                (void)xsignal(SIGINT, oldint);
-       if (oldpipe)
+       if (oldpipe != SIG_ERR)
                (void)xsignal(SIGPIPE, oldpipe);
-       if (oldalrm)
+       if (oldalrm != SIG_ERR)
                (void)xsignal(SIGALRM, oldalrm);
-       if (oldquit)
-               (void)xsignal(SIGQUIT, oldpipe);
+       if (oldquit != SIG_ERR)
+               (void)xsignal(SIGQUIT, oldquit);
        if (fin != NULL)
                fetch_close(fin);
        else if (s != -1)



Home | Main Index | Thread Index | Old Index