diff options
author | grant <grant@pkgsrc.org> | 2004-07-27 10:25:09 +0000 |
---|---|---|
committer | grant <grant@pkgsrc.org> | 2004-07-27 10:25:09 +0000 |
commit | 2a74b0885a72a7461d8c62dfa625c95b93a05da9 (patch) | |
tree | b59171e9280e3a46baed52ef68b0aa08f0eb3ad4 /net/tnftp | |
parent | a60952e252c605e068e103df8dc51ef9df0c5668 (diff) | |
download | pkgsrc-2a74b0885a72a7461d8c62dfa625c95b93a05da9.tar.gz |
apply fix from NetBSD-current for SIGINT handling. ok'd by lukem.
Diffstat (limited to 'net/tnftp')
-rw-r--r-- | net/tnftp/files/src/cmds.c | 13 | ||||
-rw-r--r-- | net/tnftp/files/src/fetch.c | 11 | ||||
-rw-r--r-- | net/tnftp/files/src/ftp.c | 16 | ||||
-rw-r--r-- | net/tnftp/files/src/ftp_var.h | 5 | ||||
-rw-r--r-- | net/tnftp/files/src/main.c | 19 | ||||
-rw-r--r-- | net/tnftp/files/src/util.c | 9 |
6 files changed, 46 insertions, 27 deletions
diff --git a/net/tnftp/files/src/cmds.c b/net/tnftp/files/src/cmds.c index e588093b053..d2571e146e0 100644 --- a/net/tnftp/files/src/cmds.c +++ b/net/tnftp/files/src/cmds.c @@ -1,7 +1,7 @@ -/* $NetBSD: cmds.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */ +/* $NetBSD: cmds.c,v 1.2 2004/07/27 10:25:09 grant Exp $ */ /*- - * Copyright (c) 1996-2002 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2004 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -108,7 +108,7 @@ #if 0 static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: cmds.c,v 1.1 2004/03/11 13:01:01 grant Exp $"); +__RCSID("$NetBSD: cmds.c,v 1.2 2004/07/27 10:25:09 grant Exp $"); #endif #endif /* not lint */ #endif @@ -1388,7 +1388,7 @@ void shell(int argc, char *argv[]) { pid_t pid; - sigfunc old1; + sigfunc oldintr; char shellnam[MAXPATHLEN], *shell, *namep; int wait_status; @@ -1397,7 +1397,7 @@ shell(int argc, char *argv[]) code = -1; return; } - old1 = xsignal(SIGINT, SIG_IGN); + oldintr = xsignal(SIGINT, SIG_IGN); if ((pid = fork()) == 0) { for (pid = 3; pid < 20; pid++) (void)close(pid); @@ -1428,7 +1428,7 @@ shell(int argc, char *argv[]) if (pid > 0) while (wait(&wait_status) != pid) ; - (void)xsignal(SIGINT, old1); + (void)xsignal(SIGINT, oldintr); if (pid == -1) { warn("Try again later"); code = -1; @@ -1778,6 +1778,7 @@ void proxabort(int notused) { + sigint_raised = 1; alarmtimer(0); if (!proxy) { pswitch(1); diff --git a/net/tnftp/files/src/fetch.c b/net/tnftp/files/src/fetch.c index e4848c16463..45025d836cd 100644 --- a/net/tnftp/files/src/fetch.c +++ b/net/tnftp/files/src/fetch.c @@ -1,7 +1,7 @@ -/* $NetBSD: fetch.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */ +/* $NetBSD: fetch.c,v 1.2 2004/07/27 10:25:09 grant Exp $ */ /*- - * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -42,7 +42,7 @@ #if 0 #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.1 2004/03/11 13:01:01 grant Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.2 2004/07/27 10:25:09 grant Exp $"); #endif /* not lint */ #endif @@ -1254,6 +1254,7 @@ aborthttp(int notused) char msgbuf[100]; int len; + sigint_raised = 1; alarmtimer(0); len = strlcpy(msgbuf, "\nHTTP fetch aborted.\n", sizeof(msgbuf)); write(fileno(ttyout), msgbuf, len); @@ -1677,7 +1678,9 @@ auto_fetch(int argc, char *argv[]) if (sigsetjmp(toplevel, 1)) { if (connected) disconnect(0, NULL); - return (argpos + 1); + if (rval > 0) + rval = argpos + 1; + return (rval); } (void)xsignal(SIGINT, intr); (void)xsignal(SIGPIPE, lostpeer); diff --git a/net/tnftp/files/src/ftp.c b/net/tnftp/files/src/ftp.c index 37cda5a7f67..68e80560c5d 100644 --- a/net/tnftp/files/src/ftp.c +++ b/net/tnftp/files/src/ftp.c @@ -1,7 +1,7 @@ -/* $NetBSD: ftp.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */ +/* $NetBSD: ftp.c,v 1.2 2004/07/27 10:25:09 grant Exp $ */ /*- - * Copyright (c) 1996-2002 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2004 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -106,7 +106,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.1 2004/03/11 13:01:01 grant Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.2 2004/07/27 10:25:09 grant Exp $"); #endif #endif /* not lint */ #endif @@ -115,8 +115,9 @@ __RCSID("$NetBSD: ftp.c,v 1.1 2004/03/11 13:01:01 grant Exp $"); #include "ftp_var.h" -volatile int abrtflag = 0; -volatile int timeoutflag = 0; +volatile sig_atomic_t abrtflag; +volatile sig_atomic_t timeoutflag; + sigjmp_buf ptabort; int ptabflg; int ptflag = 0; @@ -304,6 +305,7 @@ cmdabort(int notused) { int oerrno = errno; + sigint_raised = 1; alarmtimer(0); if (fromatty) write(fileno(ttyout), "\n", 1); @@ -587,6 +589,7 @@ abortxfer(int notused) char msgbuf[100]; int len; + sigint_raised = 1; alarmtimer(0); mflag = 0; abrtflag = 0; @@ -1725,6 +1728,7 @@ psabort(int notused) { int oerrno = errno; + sigint_raised = 1; alarmtimer(0); abrtflag++; errno = oerrno; @@ -1821,6 +1825,7 @@ void abortpt(int notused) { + sigint_raised = 1; alarmtimer(0); if (fromatty) write(fileno(ttyout), "\n", 1); @@ -2039,6 +2044,7 @@ abort_squared(int dummy) char msgbuf[100]; int len; + sigint_raised = 1; alarmtimer(0); len = strlcpy(msgbuf, "\nremote abort aborted; closing connection.\n", sizeof(msgbuf)); diff --git a/net/tnftp/files/src/ftp_var.h b/net/tnftp/files/src/ftp_var.h index ae2b7657fd6..11fd03caa41 100644 --- a/net/tnftp/files/src/ftp_var.h +++ b/net/tnftp/files/src/ftp_var.h @@ -1,7 +1,7 @@ -/* $NetBSD: ftp_var.h,v 1.1 2004/03/11 13:01:01 grant Exp $ */ +/* $NetBSD: ftp_var.h,v 1.2 2004/07/27 10:25:09 grant Exp $ */ /*- - * Copyright (c) 1996-2003 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2004 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -306,6 +306,7 @@ GLOBAL void (*reply_callback)(const char *); * first (`xxx-') and last (`xxx ') */ +GLOBAL volatile sig_atomic_t sigint_raised; GLOBAL FILE *cin; GLOBAL FILE *cout; diff --git a/net/tnftp/files/src/main.c b/net/tnftp/files/src/main.c index f17f8fe87d2..49d5a44b7bf 100644 --- a/net/tnftp/files/src/main.c +++ b/net/tnftp/files/src/main.c @@ -1,7 +1,7 @@ -/* $NetBSD: main.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */ +/* $NetBSD: main.c,v 1.2 2004/07/27 10:25:09 grant Exp $ */ /*- - * Copyright (c) 1996-2002 The NetBSD Foundation, Inc. + * Copyright (c) 1996-2004 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -109,7 +109,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\ #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94"; #else -__RCSID("$NetBSD: main.c,v 1.1 2004/03/11 13:01:01 grant Exp $"); +__RCSID("$NetBSD: main.c,v 1.2 2004/07/27 10:25:09 grant Exp $"); #endif #endif /* not lint */ #endif @@ -144,6 +144,8 @@ main(int argc, char *argv[]) #endif setprogname(argv[0]); + sigint_raised = 0; + ftpport = "ftp"; httpport = "http"; gateport = NULL; @@ -498,17 +500,22 @@ main(int argc, char *argv[]) if (argc > 0) { if (isupload) { rval = auto_put(argc, argv, upload_path); + sigint_or_rval_exit: + if (sigint_raised) { + (void)xsignal(SIGINT, SIG_DFL); + raise(SIGINT); + } exit(rval); } else if (strchr(argv[0], ':') != NULL && ! isipv6addr(argv[0])) { rval = auto_fetch(argc, argv); if (rval >= 0) /* -1 == connected and cd-ed */ - exit(rval); + goto sigint_or_rval_exit; } else { char *xargv[4], *user, *host; - if (sigsetjmp(toplevel, 1)) - exit(0); + if ((rval = sigsetjmp(toplevel, 1))) + goto sigint_or_rval_exit; (void)xsignal(SIGINT, intr); (void)xsignal(SIGPIPE, lostpeer); user = NULL; diff --git a/net/tnftp/files/src/util.c b/net/tnftp/files/src/util.c index 63f1e91f0fa..f51f23e1792 100644 --- a/net/tnftp/files/src/util.c +++ b/net/tnftp/files/src/util.c @@ -1,7 +1,7 @@ -/* $NetBSD: util.c,v 1.1 2004/03/11 13:01:01 grant Exp $ */ +/* $NetBSD: util.c,v 1.2 2004/07/27 10:25:09 grant Exp $ */ /*- - * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. + * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -76,7 +76,7 @@ #if 0 #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: util.c,v 1.1 2004/03/11 13:01:01 grant Exp $"); +__RCSID("$NetBSD: util.c,v 1.2 2004/07/27 10:25:09 grant Exp $"); #endif /* not lint */ #endif @@ -304,9 +304,10 @@ cleanuppeer(void) * Top-level signal handler for interrupted commands. */ void -intr(int dummy) +intr(int signo) { + sigint_raised = 1; alarmtimer(0); if (fromatty) write(fileno(ttyout), "\n", 1); |