Add a new back-end function to return the exit code of the remote
[u/mdw/putty] / plink.c
diff --git a/plink.c b/plink.c
index 6c21150..f8a9f7c 100644 (file)
--- a/plink.c
+++ b/plink.c
@@ -444,6 +444,7 @@ int main(int argc, char **argv)
     SOCKET *sklist;
     int skcount, sksize;
     int connopen;
+    int exitcode;
     char extra_portfwd[sizeof(cfg.portfwd)];
 
     ssh_get_line = get_line;
@@ -967,5 +968,10 @@ int main(int argc, char **argv)
            break;                     /* we closed the connection */
     }
     WSACleanup();
-    return 0;
+    exitcode = back->exitcode();
+    if (exitcode < 0) {
+       fprintf(stderr, "Remote process exit code unavailable\n");
+       exitcode = 1;                  /* this is an error condition */
+    }
+    return exitcode;
 }