2 * PLink - a command-line (stdin/stdout) variant of PuTTY.
15 #include <sys/ioctl.h>
17 #ifndef HAVE_NO_SYS_SELECT_H
18 #include <sys/select.h>
21 #define PUTTY_DO_GLOBALS /* actually _define_ globals */
26 #define MAX_STDIN_BACKLOG 4096
30 void fatalbox(char *p
, ...)
33 fprintf(stderr
, "FATAL ERROR: ");
35 vfprintf(stderr
, p
, ap
);
44 void modalfatalbox(char *p
, ...)
47 fprintf(stderr
, "FATAL ERROR: ");
49 vfprintf(stderr
, p
, ap
);
58 void connection_fatal(void *frontend
, char *p
, ...)
61 fprintf(stderr
, "FATAL ERROR: ");
63 vfprintf(stderr
, p
, ap
);
72 void cmdline_error(char *p
, ...)
75 fprintf(stderr
, "plink: ");
77 vfprintf(stderr
, p
, ap
);
83 static int local_tty
= 0; /* do we have a local tty? */
84 static struct termios orig_termios
;
87 static void *backhandle
;
91 * Default settings that are specific to pterm.
93 char *platform_default_s(const char *name
)
95 if (!strcmp(name
, "TermType"))
96 return dupstr(getenv("TERM"));
97 if (!strcmp(name
, "UserName"))
98 return get_username();
99 if (!strcmp(name
, "SerialLine"))
100 return dupstr("/dev/ttyS0");
104 int platform_default_i(const char *name
, int def
)
106 if (!strcmp(name
, "TermWidth") ||
107 !strcmp(name
, "TermHeight")) {
109 if (ioctl(0, TIOCGWINSZ
, (void *)&size
) >= 0)
110 return (!strcmp(name
, "TermWidth") ? size
.ws_col
: size
.ws_row
);
115 FontSpec
platform_default_fontspec(const char *name
)
122 Filename
platform_default_filename(const char *name
)
125 if (!strcmp(name
, "LogFileName"))
126 strcpy(ret
.path
, "putty.log");
132 char *x_get_default(const char *key
)
134 return NULL
; /* this is a stub */
136 int term_ldisc(Terminal
*term
, int mode
)
140 void ldisc_update(void *frontend
, int echo
, int edit
)
142 /* Update stdin read mode to reflect changes in line discipline. */
145 if (!local_tty
) return;
150 mode
.c_lflag
|= ECHO
;
152 mode
.c_lflag
&= ~ECHO
;
155 mode
.c_iflag
|= ICRNL
;
156 mode
.c_lflag
|= ISIG
| ICANON
;
157 mode
.c_oflag
|= OPOST
;
159 mode
.c_iflag
&= ~ICRNL
;
160 mode
.c_lflag
&= ~(ISIG
| ICANON
);
161 mode
.c_oflag
&= ~OPOST
;
162 /* Solaris sets these to unhelpful values */
164 mode
.c_cc
[VTIME
] = 0;
165 /* FIXME: perhaps what we do with IXON/IXOFF should be an
166 * argument to ldisc_update(), to allow implementation of SSH-2
167 * "xon-xoff" and Rlogin's equivalent? */
168 mode
.c_iflag
&= ~IXON
;
169 mode
.c_iflag
&= ~IXOFF
;
172 * Mark parity errors and (more important) BREAK on input. This
173 * is more complex than it need be because POSIX-2001 suggests
174 * that escaping of valid 0xff in the input stream is dependent on
175 * IGNPAR being clear even though marking of BREAK isn't. NetBSD
176 * 2.0 goes one worse and makes it dependent on INPCK too. We
177 * deal with this by forcing these flags into a useful state and
178 * then faking the state in which we found them in from_tty() if
179 * we get passed a parity or framing error.
181 mode
.c_iflag
= (mode
.c_iflag
| INPCK
| PARMRK
) & ~IGNPAR
;
183 tcsetattr(0, TCSANOW
, &mode
);
186 /* Helper function to extract a special character from a termios. */
187 static char *get_ttychar(struct termios
*t
, int index
)
189 cc_t c
= t
->c_cc
[index
];
190 #if defined(_POSIX_VDISABLE)
191 if (c
== _POSIX_VDISABLE
)
192 return dupprintf("");
194 return dupprintf("^<%d>", c
);
197 char *get_ttymode(void *frontend
, const char *mode
)
200 * Propagate appropriate terminal modes from the local terminal,
203 if (!local_tty
) return NULL
;
205 #define GET_CHAR(ourname, uxname) \
207 if (strcmp(mode, ourname) == 0) \
208 return get_ttychar(&orig_termios, uxname); \
210 #define GET_BOOL(ourname, uxname, uxmemb, transform) \
212 if (strcmp(mode, ourname) == 0) { \
213 int b = (orig_termios.uxmemb & uxname) != 0; \
215 return dupprintf("%d", b); \
220 * Modes that want to be the same on all terminal devices involved.
222 /* All the special characters supported by SSH */
224 GET_CHAR("INTR", VINTR
);
227 GET_CHAR("QUIT", VQUIT
);
230 GET_CHAR("ERASE", VERASE
);
233 GET_CHAR("KILL", VKILL
);
236 GET_CHAR("EOF", VEOF
);
239 GET_CHAR("EOL", VEOL
);
242 GET_CHAR("EOL2", VEOL2
);
245 GET_CHAR("START", VSTART
);
248 GET_CHAR("STOP", VSTOP
);
251 GET_CHAR("SUSP", VSUSP
);
254 GET_CHAR("DSUSP", VDSUSP
);
256 #if defined(VREPRINT)
257 GET_CHAR("REPRINT", VREPRINT
);
260 GET_CHAR("WERASE", VWERASE
);
263 GET_CHAR("LNEXT", VLNEXT
);
266 GET_CHAR("FLUSH", VFLUSH
);
269 GET_CHAR("SWTCH", VSWTCH
);
272 GET_CHAR("STATUS", VSTATUS
);
274 #if defined(VDISCARD)
275 GET_CHAR("DISCARD", VDISCARD
);
277 /* Modes that "configure" other major modes. These should probably be
278 * considered as user preferences. */
279 /* Configuration of ICANON */
281 GET_BOOL("ECHOK", ECHOK
, c_lflag
, );
284 GET_BOOL("ECHOKE", ECHOKE
, c_lflag
, );
287 GET_BOOL("ECHOE", ECHOE
, c_lflag
, );
290 GET_BOOL("ECHONL", ECHONL
, c_lflag
, );
293 GET_BOOL("XCASE", XCASE
, c_lflag
, );
295 /* Configuration of ECHO */
297 GET_BOOL("ECHOCTL", ECHOCTL
, c_lflag
, );
299 /* Configuration of IXON/IXOFF */
301 GET_BOOL("IXANY", IXANY
, c_iflag
, );
303 /* Configuration of OPOST */
305 GET_BOOL("OLCUC", OLCUC
, c_oflag
, );
308 GET_BOOL("ONLCR", ONLCR
, c_oflag
, );
311 GET_BOOL("OCRNL", OCRNL
, c_oflag
, );
314 GET_BOOL("ONOCR", ONOCR
, c_oflag
, );
317 GET_BOOL("ONLRET", ONLRET
, c_oflag
, );
321 * Modes that want to be set in only one place, and that we have
325 GET_BOOL("ISIG", ISIG
, c_lflag
, );
328 GET_BOOL("ICANON", ICANON
, c_lflag
, );
331 GET_BOOL("ECHO", ECHO
, c_lflag
, );
334 GET_BOOL("IXON", IXON
, c_iflag
, );
337 GET_BOOL("IXOFF", IXOFF
, c_iflag
, );
340 GET_BOOL("OPOST", OPOST
, c_oflag
, );
344 * We do not propagate the following modes:
345 * - Parity/serial settings, which are a local affair and don't
346 * make sense propagated over SSH's 8-bit byte-stream.
347 * IGNPAR PARMRK INPCK CS7 CS8 PARENB PARODD
348 * - Things that want to be enabled in one place that we don't
353 * - Things I don't know what to do with. (FIXME)
354 * ISTRIP IMAXBEL NOFLSH TOSTOP IEXTEN
361 /* Fall through to here for unrecognised names, or ones that are
362 * unsupported on this platform */
366 void cleanup_termios(void)
369 tcsetattr(0, TCSANOW
, &orig_termios
);
372 bufchain stdout_data
, stderr_data
;
374 void try_output(int is_stderr
)
376 bufchain
*chain
= (is_stderr ?
&stderr_data
: &stdout_data
);
377 int fd
= (is_stderr ?
2 : 1);
381 if (bufchain_size(chain
) == 0)
384 bufchain_prefix(chain
, &senddata
, &sendlen
);
385 ret
= write(fd
, senddata
, sendlen
);
387 bufchain_consume(chain
, ret
);
389 perror(is_stderr ?
"stderr: write" : "stdout: write");
394 int from_backend(void *frontend_handle
, int is_stderr
,
395 const char *data
, int len
)
400 bufchain_add(&stderr_data
, data
, len
);
403 bufchain_add(&stdout_data
, data
, len
);
407 osize
= bufchain_size(&stdout_data
);
408 esize
= bufchain_size(&stderr_data
);
410 return osize
+ esize
;
413 int from_backend_untrusted(void *frontend_handle
, const char *data
, int len
)
416 * No "untrusted" output should get here (the way the code is
417 * currently, it's all diverted by FLAG_STDERR).
419 assert(!"Unexpected call to from_backend_untrusted()");
420 return 0; /* not reached */
423 int get_userpass_input(prompts_t
*p
, unsigned char *in
, int inlen
)
426 ret
= cmdline_get_passwd_input(p
, in
, inlen
);
428 ret
= console_get_userpass_input(p
, in
, inlen
);
433 * Handle data from a local tty in PARMRK format.
435 static void from_tty(void *vbuf
, unsigned len
)
437 char *p
, *q
, *end
, *buf
= vbuf
;
438 static enum {NORMAL
, FF
, FF00
} state
= NORMAL
;
440 p
= buf
; end
= buf
+ len
;
448 q
= memchr(p
, '\xff', end
- p
);
449 if (q
== NULL
) q
= end
;
450 back
->send(backhandle
, p
, q
- p
);
456 back
->send(backhandle
, p
, 1);
459 } else if (*p
== '\0') {
466 back
->special(backhandle
, TS_BRK
);
469 * Pretend that PARMRK wasn't set. This involves
470 * faking what INPCK and IGNPAR would have done if
471 * we hadn't overridden them. Unfortunately, we
472 * can't do this entirely correctly because INPCK
473 * distinguishes between framing and parity
474 * errors, but PARMRK format represents both in
475 * the same way. We assume that parity errors are
476 * more common than framing errors, and hence
477 * treat all input errors as being subject to
480 if (orig_termios
.c_iflag
& INPCK
) {
481 /* If IGNPAR is set, we throw away the character. */
482 if (!(orig_termios
.c_iflag
& IGNPAR
)) {
483 /* PE/FE get passed on as NUL. */
485 back
->send(backhandle
, p
, 1);
488 /* INPCK not set. Assume we got a parity error. */
489 back
->send(backhandle
, p
, 1);
500 void sigwinch(int signum
)
502 write(signalpipe
[1], "x", 1);
506 * In Plink our selects are synchronous, so these functions are
509 int uxsel_input_add(int fd
, int rwx
) { return 0; }
510 void uxsel_input_remove(int id
) { }
513 * Short description of parameters.
515 static void usage(void)
517 printf("PuTTY Link: command-line connection utility\n");
519 printf("Usage: plink [options] [user@]host [command]\n");
520 printf(" (\"host\" can also be a PuTTY saved session name)\n");
521 printf("Options:\n");
522 printf(" -V print version information and exit\n");
523 printf(" -pgpfp print PGP key fingerprints and exit\n");
524 printf(" -v show verbose messages\n");
525 printf(" -load sessname Load settings from saved session\n");
526 printf(" -ssh -telnet -rlogin -raw\n");
527 printf(" force use of a particular protocol\n");
528 printf(" -P port connect to specified port\n");
529 printf(" -l user connect with specified username\n");
530 printf(" -batch disable all interactive prompts\n");
531 printf("The following options only apply to SSH connections:\n");
532 printf(" -pw passw login with specified password\n");
533 printf(" -D [listen-IP:]listen-port\n");
534 printf(" Dynamic SOCKS-based port forwarding\n");
535 printf(" -L [listen-IP:]listen-port:host:port\n");
536 printf(" Forward local port to remote address\n");
537 printf(" -R [listen-IP:]listen-port:host:port\n");
538 printf(" Forward remote port to local address\n");
539 printf(" -X -x enable / disable X11 forwarding\n");
540 printf(" -A -a enable / disable agent forwarding\n");
541 printf(" -t -T enable / disable pty allocation\n");
542 printf(" -1 -2 force use of particular protocol version\n");
543 printf(" -4 -6 force use of IPv4 or IPv6\n");
544 printf(" -C enable compression\n");
545 printf(" -i key private key file for authentication\n");
546 printf(" -noagent disable use of Pageant\n");
547 printf(" -agent enable use of Pageant\n");
548 printf(" -m file read remote command(s) from file\n");
549 printf(" -s remote command is an SSH subsystem (SSH-2 only)\n");
550 printf(" -N don't start a shell/command (SSH-2 only)\n");
551 printf(" -nc host:port\n");
552 printf(" open tunnel in place of session (SSH-2 only)\n");
556 static void version(void)
558 printf("plink: %s\n", ver
);
562 int main(int argc
, char **argv
)
568 int i
, fdcount
, fdsize
, fdstate
;
572 int use_subsystem
= 0;
577 fdcount
= fdsize
= 0;
579 * Initialise port and protocol to sensible defaults. (These
580 * will be overridden by more or less anything.)
582 default_protocol
= PROT_SSH
;
587 * Process the command line.
589 do_defaults(NULL
, &cfg
);
590 loaded_session
= FALSE
;
591 default_protocol
= cfg
.protocol
;
592 default_port
= cfg
.port
;
596 * Override the default protocol if PLINK_PROTOCOL is set.
598 char *p
= getenv("PLINK_PROTOCOL");
600 const Backend
*b
= backend_from_name(p
);
602 default_protocol
= cfg
.protocol
= b
->protocol
;
603 default_port
= cfg
.port
= b
->default_port
;
610 int ret
= cmdline_process_param(p
, (argc
> 1 ? argv
[1] : NULL
),
614 "plink: option \"%s\" requires an argument\n", p
);
616 } else if (ret
== 2) {
618 } else if (ret
== 1) {
620 } else if (!strcmp(p
, "-batch")) {
621 console_batch_mode
= 1;
622 } else if (!strcmp(p
, "-s")) {
623 /* Save status to write to cfg later. */
625 } else if (!strcmp(p
, "-V")) {
627 } else if (!strcmp(p
, "-pgpfp")) {
630 } else if (!strcmp(p
, "-o")) {
633 "plink: option \"-o\" requires an argument\n");
637 provide_xrm_string(*++argv
);
640 fprintf(stderr
, "plink: unknown option \"%s\"\n", p
);
644 if (!cfg_launchable(&cfg
)) {
648 * If the hostname starts with "telnet:", set the
649 * protocol to Telnet and process the string as a
652 if (!strncmp(q
, "telnet:", 7)) {
656 if (q
[0] == '/' && q
[1] == '/')
658 cfg
.protocol
= PROT_TELNET
;
660 while (*p
&& *p
!= ':' && *p
!= '/')
669 strncpy(cfg
.host
, q
, sizeof(cfg
.host
) - 1);
670 cfg
.host
[sizeof(cfg
.host
) - 1] = '\0';
672 char *r
, *user
, *host
;
674 * Before we process the [user@]host string, we
675 * first check for the presence of a protocol
676 * prefix (a protocol name followed by ",").
682 b
= backend_from_name(p
);
684 default_protocol
= cfg
.protocol
= b
->protocol
;
685 portnumber
= b
->default_port
;
691 * A nonzero length string followed by an @ is treated
692 * as a username. (We discount an _initial_ @.) The
693 * rest of the string (or the whole string if no @)
694 * is treated as a session name and/or hostname.
698 p
++, r
= NULL
; /* discount initial @ */
703 user
= NULL
, host
= p
;
707 * Now attempt to load a saved session with the
708 * same name as the hostname.
712 do_defaults(host
, &cfg2
);
713 if (loaded_session
|| !cfg_launchable(&cfg2
)) {
714 /* No settings for this host; use defaults */
715 /* (or session was already loaded with -load) */
716 strncpy(cfg
.host
, host
, sizeof(cfg
.host
) - 1);
717 cfg
.host
[sizeof(cfg
.host
) - 1] = '\0';
718 cfg
.port
= default_port
;
725 /* Patch in specified username. */
726 strncpy(cfg
.username
, user
,
727 sizeof(cfg
.username
) - 1);
728 cfg
.username
[sizeof(cfg
.username
) - 1] = '\0';
735 cmdlen
= cmdsize
= 0;
740 if (cmdlen
>= cmdsize
) {
741 cmdsize
= cmdlen
+ 512;
742 command
= sresize(command
, cmdsize
, char);
744 command
[cmdlen
++]=*p
++;
746 if (cmdlen
>= cmdsize
) {
747 cmdsize
= cmdlen
+ 512;
748 command
= sresize(command
, cmdsize
, char);
750 command
[cmdlen
++]=' '; /* always add trailing space */
751 if (--argc
) p
= *++argv
;
753 if (cmdlen
) command
[--cmdlen
]='\0';
754 /* change trailing blank to NUL */
755 cfg
.remote_cmd_ptr
= command
;
756 cfg
.remote_cmd_ptr2
= NULL
;
757 cfg
.nopty
= TRUE
; /* command => no terminal */
759 break; /* done with cmdline */
767 if (!cfg_launchable(&cfg
)) {
772 * Trim leading whitespace off the hostname if it's there.
775 int space
= strspn(cfg
.host
, " \t");
776 memmove(cfg
.host
, cfg
.host
+space
, 1+strlen(cfg
.host
)-space
);
779 /* See if host is of the form user@host */
780 if (cfg
.host
[0] != '\0') {
781 char *atsign
= strrchr(cfg
.host
, '@');
782 /* Make sure we're not overflowing the user field */
784 if (atsign
- cfg
.host
< sizeof cfg
.username
) {
785 strncpy(cfg
.username
, cfg
.host
, atsign
- cfg
.host
);
786 cfg
.username
[atsign
- cfg
.host
] = '\0';
788 memmove(cfg
.host
, atsign
+ 1, 1 + strlen(atsign
+ 1));
793 * Perform command-line overrides on session configuration.
795 cmdline_run_saved(&cfg
);
798 * Apply subsystem status.
801 cfg
.ssh_subsys
= TRUE
;
804 * Trim a colon suffix off the hostname if it's there.
806 cfg
.host
[strcspn(cfg
.host
, ":")] = '\0';
809 * Remove any remaining whitespace from the hostname.
813 while (cfg
.host
[p2
] != '\0') {
814 if (cfg
.host
[p2
] != ' ' && cfg
.host
[p2
] != '\t') {
815 cfg
.host
[p1
] = cfg
.host
[p2
];
823 if (!cfg
.remote_cmd_ptr
&& !*cfg
.remote_cmd
&& !*cfg
.ssh_nc_host
)
824 flags
|= FLAG_INTERACTIVE
;
827 * Select protocol. This is farmed out into a table in a
828 * separate file to enable an ssh-free variant.
830 back
= backend_from_proto(cfg
.protocol
);
833 "Internal fault: Unsupported protocol found\n");
840 if (portnumber
!= -1)
841 cfg
.port
= portnumber
;
844 * Set up the pipe we'll use to tell us about SIGWINCH.
846 if (pipe(signalpipe
) < 0) {
850 putty_signal(SIGWINCH
, sigwinch
);
856 * Start up the connection.
858 logctx
= log_init(NULL
, &cfg
);
859 console_provide_logctx(logctx
);
863 /* nodelay is only useful if stdin is a terminal device */
864 int nodelay
= cfg
.tcp_nodelay
&& isatty(0);
866 error
= back
->init(NULL
, &backhandle
, &cfg
, cfg
.host
, cfg
.port
,
867 &realhost
, nodelay
, cfg
.tcp_keepalives
);
869 fprintf(stderr
, "Unable to open connection:\n%s\n", error
);
872 back
->provide_logctx(backhandle
, logctx
);
873 ldisc
= ldisc_create(&cfg
, NULL
, back
, backhandle
, NULL
);
879 * Set up the initial console mode. We don't care if this call
880 * fails, because we know we aren't necessarily running in a
883 local_tty
= (tcgetattr(0, &orig_termios
) == 0);
884 atexit(cleanup_termios
);
885 ldisc_update(NULL
, 1, 1);
887 now
= GETTICKCOUNT();
890 fd_set rset
, wset
, xset
;
900 FD_SET_MAX(signalpipe
[0], maxfd
, rset
);
902 if (connopen
&& !sending
&&
903 back
->connected(backhandle
) &&
904 back
->sendok(backhandle
) &&
905 back
->sendbuffer(backhandle
) < MAX_STDIN_BACKLOG
) {
906 /* If we're OK to send, then try to read from stdin. */
907 FD_SET_MAX(0, maxfd
, rset
);
910 if (bufchain_size(&stdout_data
) > 0) {
911 /* If we have data for stdout, try to write to stdout. */
912 FD_SET_MAX(1, maxfd
, wset
);
915 if (bufchain_size(&stderr_data
) > 0) {
916 /* If we have data for stderr, try to write to stderr. */
917 FD_SET_MAX(2, maxfd
, wset
);
920 /* Count the currently active fds. */
922 for (fd
= first_fd(&fdstate
, &rwx
); fd
>= 0;
923 fd
= next_fd(&fdstate
, &rwx
)) i
++;
925 /* Expand the fdlist buffer if necessary. */
928 fdlist
= sresize(fdlist
, fdsize
, int);
932 * Add all currently open fds to the select sets, and store
933 * them in fdlist as well.
936 for (fd
= first_fd(&fdstate
, &rwx
); fd
>= 0;
937 fd
= next_fd(&fdstate
, &rwx
)) {
938 fdlist
[fdcount
++] = fd
;
940 FD_SET_MAX(fd
, maxfd
, rset
);
942 FD_SET_MAX(fd
, maxfd
, wset
);
944 FD_SET_MAX(fd
, maxfd
, xset
);
949 struct timeval tv
, *ptv
;
951 if (run_timers(now
, &next
)) {
952 ticks
= next
- GETTICKCOUNT();
953 if (ticks
< 0) ticks
= 0; /* just in case */
954 tv
.tv_sec
= ticks
/ 1000;
955 tv
.tv_usec
= ticks
% 1000 * 1000;
960 ret
= select(maxfd
, &rset
, &wset
, &xset
, ptv
);
964 long newnow
= GETTICKCOUNT();
966 * Check to see whether the system clock has
967 * changed massively during the select.
969 if (newnow
- now
< 0 || newnow
- now
> next
- now
) {
971 * If so, look at the elapsed time in the
972 * select and use it to compute a new
975 long othernow
= now
+ tv
.tv_sec
* 1000 + tv
.tv_usec
/ 1000;
976 /* So we'd like GETTICKCOUNT to have returned othernow,
977 * but instead it return newnow. Hence ... */
978 tickcount_offset
+= othernow
- newnow
;
984 } while (ret
< 0 && errno
== EINTR
);
991 for (i
= 0; i
< fdcount
; i
++) {
994 * We must process exceptional notifications before
995 * ordinary readability ones, or we may go straight
996 * past the urgent marker.
998 if (FD_ISSET(fd
, &xset
))
999 select_result(fd
, 4);
1000 if (FD_ISSET(fd
, &rset
))
1001 select_result(fd
, 1);
1002 if (FD_ISSET(fd
, &wset
))
1003 select_result(fd
, 2);
1006 if (FD_ISSET(signalpipe
[0], &rset
)) {
1008 struct winsize size
;
1009 read(signalpipe
[0], c
, 1); /* ignore its value; it'll be `x' */
1010 if (ioctl(0, TIOCGWINSZ
, (void *)&size
) >= 0)
1011 back
->size(backhandle
, size
.ws_col
, size
.ws_row
);
1014 if (FD_ISSET(0, &rset
)) {
1018 if (connopen
&& back
->connected(backhandle
)) {
1019 ret
= read(0, buf
, sizeof(buf
));
1021 perror("stdin: read");
1023 } else if (ret
== 0) {
1024 back
->special(backhandle
, TS_EOF
);
1025 sending
= FALSE
; /* send nothing further after this */
1030 back
->send(backhandle
, buf
, ret
);
1035 if (FD_ISSET(1, &wset
)) {
1039 if (FD_ISSET(2, &wset
)) {
1043 if ((!connopen
|| !back
->connected(backhandle
)) &&
1044 bufchain_size(&stdout_data
) == 0 &&
1045 bufchain_size(&stderr_data
) == 0)
1046 break; /* we closed the connection */
1048 exitcode
= back
->exitcode(backhandle
);
1050 fprintf(stderr
, "Remote process exit code unavailable\n");
1051 exitcode
= 1; /* this is an error condition */
1053 cleanup_exit(exitcode
);
1054 return exitcode
; /* shouldn't happen, but placates gcc */