diff options
Diffstat (limited to 'clientloop.c')
-rw-r--r-- | clientloop.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/clientloop.c b/clientloop.c index 70abee8fd..3a1b43dda 100644 --- a/clientloop.c +++ b/clientloop.c | |||
@@ -59,7 +59,7 @@ | |||
59 | */ | 59 | */ |
60 | 60 | ||
61 | #include "includes.h" | 61 | #include "includes.h" |
62 | RCSID("$OpenBSD: clientloop.c,v 1.74 2001/05/31 10:30:15 markus Exp $"); | 62 | RCSID("$OpenBSD: clientloop.c,v 1.75 2001/06/04 23:07:20 markus Exp $"); |
63 | 63 | ||
64 | #include "ssh.h" | 64 | #include "ssh.h" |
65 | #include "ssh1.h" | 65 | #include "ssh1.h" |
@@ -102,6 +102,7 @@ extern char *host; | |||
102 | * because this is updated in a signal handler. | 102 | * because this is updated in a signal handler. |
103 | */ | 103 | */ |
104 | static volatile int received_window_change_signal = 0; | 104 | static volatile int received_window_change_signal = 0; |
105 | static volatile int received_signal = 0; | ||
105 | 106 | ||
106 | /* Flag indicating whether the user\'s terminal is in non-blocking mode. */ | 107 | /* Flag indicating whether the user\'s terminal is in non-blocking mode. */ |
107 | static int in_non_blocking_mode = 0; | 108 | static int in_non_blocking_mode = 0; |
@@ -171,13 +172,8 @@ window_change_handler(int sig) | |||
171 | void | 172 | void |
172 | signal_handler(int sig) | 173 | signal_handler(int sig) |
173 | { | 174 | { |
174 | if (in_raw_mode()) | 175 | received_signal = sig; |
175 | leave_raw_mode(); | 176 | quit_pending = 1; |
176 | if (in_non_blocking_mode) | ||
177 | leave_non_blocking(); | ||
178 | channel_stop_listening(); | ||
179 | packet_close(); | ||
180 | fatal("Killed by signal %d.", sig); | ||
181 | } | 177 | } |
182 | 178 | ||
183 | /* | 179 | /* |
@@ -933,14 +929,8 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
933 | /* Stop listening for connections. */ | 929 | /* Stop listening for connections. */ |
934 | channel_stop_listening(); | 930 | channel_stop_listening(); |
935 | 931 | ||
936 | /* | 932 | if (have_pty) |
937 | * In interactive mode (with pseudo tty) display a message indicating | 933 | leave_raw_mode(); |
938 | * that the connection has been closed. | ||
939 | */ | ||
940 | if (have_pty && options.log_level != SYSLOG_LEVEL_QUIET) { | ||
941 | snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host); | ||
942 | buffer_append(&stderr_buffer, buf, strlen(buf)); | ||
943 | } | ||
944 | 934 | ||
945 | /* restore blocking io */ | 935 | /* restore blocking io */ |
946 | if (!isatty(fileno(stdin))) | 936 | if (!isatty(fileno(stdin))) |
@@ -950,6 +940,21 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
950 | if (!isatty(fileno(stderr))) | 940 | if (!isatty(fileno(stderr))) |
951 | unset_nonblock(fileno(stderr)); | 941 | unset_nonblock(fileno(stderr)); |
952 | 942 | ||
943 | if (received_signal) { | ||
944 | if (in_non_blocking_mode) /* XXX */ | ||
945 | leave_non_blocking(); | ||
946 | fatal("Killed by signal %d.", received_signal); | ||
947 | } | ||
948 | |||
949 | /* | ||
950 | * In interactive mode (with pseudo tty) display a message indicating | ||
951 | * that the connection has been closed. | ||
952 | */ | ||
953 | if (have_pty && options.log_level != SYSLOG_LEVEL_QUIET) { | ||
954 | snprintf(buf, sizeof buf, "Connection to %.64s closed.\r\n", host); | ||
955 | buffer_append(&stderr_buffer, buf, strlen(buf)); | ||
956 | } | ||
957 | |||
953 | /* Output any buffered data for stdout. */ | 958 | /* Output any buffered data for stdout. */ |
954 | while (buffer_len(&stdout_buffer) > 0) { | 959 | while (buffer_len(&stdout_buffer) > 0) { |
955 | len = write(fileno(stdout), buffer_ptr(&stdout_buffer), | 960 | len = write(fileno(stdout), buffer_ptr(&stdout_buffer), |
@@ -974,9 +979,6 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) | |||
974 | stderr_bytes += len; | 979 | stderr_bytes += len; |
975 | } | 980 | } |
976 | 981 | ||
977 | if (have_pty) | ||
978 | leave_raw_mode(); | ||
979 | |||
980 | /* Clear and free any buffers. */ | 982 | /* Clear and free any buffers. */ |
981 | memset(buf, 0, sizeof(buf)); | 983 | memset(buf, 0, sizeof(buf)); |
982 | buffer_free(&stdin_buffer); | 984 | buffer_free(&stdin_buffer); |