=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/sftp.c,v retrieving revision 1.210 retrieving revision 1.211 diff -u -r1.210 -r1.211 --- src/usr.bin/ssh/sftp.c 2021/08/07 00:12:09 1.210 +++ src/usr.bin/ssh/sftp.c 2021/08/12 09:59:00 1.211 @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.210 2021/08/07 00:12:09 djm Exp $ */ +/* $OpenBSD: sftp.c,v 1.211 2021/08/12 09:59:00 schwarze Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -230,6 +230,13 @@ errno = olderrno; } +/* ARGSUSED */ +static void +read_interrupt(int signo) +{ + interrupted = 1; +} + /*ARGSUSED*/ static void sigchld_handler(int sig) @@ -2168,9 +2175,8 @@ const char *line; int count = 0; - ssh_signal(SIGINT, SIG_IGN); - if (el == NULL) { + ssh_signal(SIGINT, SIG_IGN); if (interactive) printf("sftp> "); if (fgets(cmd, sizeof(cmd), infile) == NULL) { @@ -2179,9 +2185,21 @@ break; } } else { + struct sigaction sa; + + interrupted = 0; + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = read_interrupt; + if (sigaction(SIGINT, &sa, NULL) == -1) { + debug3("sigaction(%s): %s", + strsignal(SIGINT), strerror(errno)); + break; + } if ((line = el_gets(el, &count)) == NULL || count <= 0) { printf("\n"); + if (interrupted) + continue; break; } history(hl, &hev, H_ENTER, line);