diff options
Diffstat (limited to 'ssh.c')
-rw-r--r-- | ssh.c | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh.c,v 1.295 2007/01/03 03:01:40 stevesk Exp $ */ | 1 | /* $OpenBSD: ssh.c,v 1.296 2007/06/12 11:11:08 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -1458,25 +1458,28 @@ control_client(const char *path) | |||
1458 | 1458 | ||
1459 | /* Stick around until the controlee closes the client_fd */ | 1459 | /* Stick around until the controlee closes the client_fd */ |
1460 | exitval = 0; | 1460 | exitval = 0; |
1461 | for (;!control_client_terminate;) { | 1461 | for (i = 0; !control_client_terminate && i < (int)sizeof(exitval);) { |
1462 | r = read(sock, &exitval, sizeof(exitval)); | 1462 | r = read(sock, (char *)&exitval + i, sizeof(exitval) - i); |
1463 | if (r == 0) { | 1463 | if (r == 0) { |
1464 | debug2("Received EOF from master"); | 1464 | debug2("Received EOF from master"); |
1465 | break; | 1465 | break; |
1466 | } | 1466 | } |
1467 | if (r > 0) | ||
1468 | debug2("Received exit status from master %d", exitval); | ||
1469 | if (r == -1 && errno != EINTR) | 1467 | if (r == -1 && errno != EINTR) |
1470 | fatal("%s: read %s", __func__, strerror(errno)); | 1468 | fatal("%s: read %s", __func__, strerror(errno)); |
1469 | i += r; | ||
1471 | } | 1470 | } |
1472 | |||
1473 | if (control_client_terminate) | ||
1474 | debug2("Exiting on signal %d", control_client_terminate); | ||
1475 | |||
1476 | close(sock); | 1471 | close(sock); |
1477 | |||
1478 | leave_raw_mode(); | 1472 | leave_raw_mode(); |
1479 | 1473 | ||
1474 | if (control_client_terminate) { | ||
1475 | debug2("Exiting on signal %d", control_client_terminate); | ||
1476 | exitval = 255; | ||
1477 | } else if (i < (int)sizeof(exitval)) { | ||
1478 | debug2("Control master terminated unexpectedly"); | ||
1479 | exitval = 255; | ||
1480 | } else | ||
1481 | debug2("Received exit status from master %d", exitval); | ||
1482 | |||
1480 | if (tty_flag && options.log_level != SYSLOG_LEVEL_QUIET) | 1483 | if (tty_flag && options.log_level != SYSLOG_LEVEL_QUIET) |
1481 | fprintf(stderr, "Connection to master closed.\r\n"); | 1484 | fprintf(stderr, "Connection to master closed.\r\n"); |
1482 | 1485 | ||