summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2021-08-09 07:21:02 +0000
committerDamien Miller <djm@cvs.openbsd.org>2021-08-09 07:21:02 +0000
commit83577f57ab65295d1beb5b5b0cf2ecaf629850eb (patch)
tree47f42944d5e522fd76c920ea1ce2c73dfbb679c9
parent271571ec5f8391e8a3bbe7cf355a1b9087052229 (diff)
on fatal errors, make scp wait for ssh connection before exiting
avoids LogLevel=verbose (or greater) messages from ssh appearing after scp has returned exited and control has returned to the shell; ok markus@ (this was originally committed as r1.223 along with unrelated stuff that I rolled back in r1.224)
-rw-r--r--usr.bin/ssh/scp.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c
index ba023c290c8..7eb541b5230 100644
--- a/usr.bin/ssh/scp.c
+++ b/usr.bin/ssh/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.224 2021/08/09 07:19:12 djm Exp $ */
+/* $OpenBSD: scp.c,v 1.225 2021/08/09 07:21:01 djm Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@@ -2096,3 +2096,21 @@ lostconn(int signo)
else
exit(1);
}
+
+void
+cleanup_exit(int i)
+{
+ if (remin > 0)
+ close(remin);
+ if (remout > 0)
+ close(remout);
+ if (remin2 > 0)
+ close(remin2);
+ if (remout2 > 0)
+ close(remout2);
+ if (do_cmd_pid > 0)
+ waitpid(do_cmd_pid, NULL, 0);
+ if (do_cmd_pid2 > 0)
+ waitpid(do_cmd_pid2, NULL, 0);
+ exit(i);
+}