summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c49
1 files changed, 26 insertions, 23 deletions
diff --git a/clientloop.c b/clientloop.c
index 7e6fe269a..e8cd49988 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.85 2001/10/24 08:51:35 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.86 2001/10/24 19:57:40 markus Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -522,36 +522,19 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
522 continue; 522 continue;
523 523
524 case '&': 524 case '&':
525 /* XXX does not work yet with proto 2 */
526 if (compat20)
527 continue;
528 /* 525 /*
529 * Detach the program (continue to serve connections, 526 * Detach the program (continue to serve connections,
530 * but put in background and no more new connections). 527 * but put in background and no more new connections).
531 */ 528 */
532 if (!stdin_eof) {
533 /*
534 * Sending SSH_CMSG_EOF alone does not always appear
535 * to be enough. So we try to send an EOF character
536 * first.
537 */
538 packet_start(SSH_CMSG_STDIN_DATA);
539 packet_put_string("\004", 1);
540 packet_send();
541 /* Close stdin. */
542 stdin_eof = 1;
543 if (buffer_len(bin) == 0) {
544 packet_start(SSH_CMSG_EOF);
545 packet_send();
546 }
547 }
548 /* Restore tty modes. */ 529 /* Restore tty modes. */
549 leave_raw_mode(); 530 leave_raw_mode();
550 531
551 /* Stop listening for new connections. */ 532 /* Stop listening for new connections. */
552 channel_close_all(); /* proto1 only XXXX */ 533 channel_stop_listening();
553 534
554 printf("%c& [backgrounded]\n", escape_char); 535 snprintf(string, sizeof string,
536 "%c& [backgrounded]\n", escape_char);
537 buffer_append(berr, string, strlen(string));
555 538
556 /* Fork into background. */ 539 /* Fork into background. */
557 pid = fork(); 540 pid = fork();
@@ -564,7 +547,27 @@ process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
564 exit(0); 547 exit(0);
565 } 548 }
566 /* The child continues serving connections. */ 549 /* The child continues serving connections. */
567 continue; /*XXX ? */ 550 if (compat20) {
551 buffer_append(bin, "\004", 1);
552 /* fake EOF on stdin */
553 return -1;
554 } else if (!stdin_eof) {
555 /*
556 * Sending SSH_CMSG_EOF alone does not always appear
557 * to be enough. So we try to send an EOF character
558 * first.
559 */
560 packet_start(SSH_CMSG_STDIN_DATA);
561 packet_put_string("\004", 1);
562 packet_send();
563 /* Close stdin. */
564 stdin_eof = 1;
565 if (buffer_len(bin) == 0) {
566 packet_start(SSH_CMSG_EOF);
567 packet_send();
568 }
569 }
570 continue;
568 571
569 case '?': 572 case '?':
570 snprintf(string, sizeof string, 573 snprintf(string, sizeof string,